Latvia states of Northern and Eastern Europe were divided into German and Soviet "spheres of influence". In the north, Latvia, Finland and Estonia were assigned to the Soviet sphere. A week later, on 1 September 1939, Germany and on 17 September, the Soviet Union invaded Poland. After the conclusion of the Molotov-Ribbentrop Pact, most of the Baltic Germans left Latvia by agreement between Ulmanis' government and Nazi Germany under the Heim ins Reich programme. In total 50,000 Baltic Germans left by the deadline of December 1939, with 1,600 remaining to conclude business and 13,000 choosing to remain in Latvia. Most of
Poland–Russia border border is 232 km long. For most of this length, the Polish side is in the Warmian-Masurian Voivodeship; the extreme east is in the Podlaskie Voivodeship, and the westernmost segment (on the Vistula Spit) in the Pomeranian Voivodeship. 210 km of the border is land and 22 km is sea. The official demarcation of the boundary was finalized March 5, 1957, in the following terms: When Poland joined the European Union in 2004, this border became one of the borders between the European Union and the non-EU countries. It is one of the five borders that Russia shares with the