Korean Empire, the former South Korea, did exist. And even if the Korean war divided the peninsula into tow nation-states, South Korea considers itself as the main continuity of the precedent Korean nation, officially calling itself "Republic of Korea'' and using the same flag design as the Empire's (though North Korea pretends to be the only legitimate Korea as well). Forgetting some details, the same goes with South Sudan separating from Sudan : Sudan doesn't become another country because of that, even if the territorial and political changes aren't negligible. But correct me if I'm wrong somewhere.
Portugal's actual flag represents the country since 1911, meaning it should be the number 30 (unless there are other country flags that I don't know that are also not considered here).