In Latvia, Russians have been the largest ethnic minority in the country for the last two centuries. The number of Russians in Latvia more than quadrupled during the Soviet occupation of Latvia when the size of the community grew from 8.8% of the total population in 1935 (206,499) to 34.0% in 1989 (905,515). It started to decrease in size again after Latvia regained independence in 1991 falling to 24.2% at the beginning of 2022. Ancient Latvia The Latvian word krievi for "Russians" and Krievija for "Russia" (and Krievzeme for Ruthenia) is thought to have originated from Krivichs, one of the tribal unions of Early East Slavs. During the 11th–12th centuries, Jersika and Koknese, principalities in Eastern Latvia paid tribute to the Principality of Polatsk. Livonia Koknese was taken by the Livonian Brothers of the Sword in 1208 and Jersika in 1209 and later both incorporated into Terra Mariana (Livonia). Early trade East Slavic presence remained, primarily as merchants in cities; trading ties to Muscovy and other parts of what is now Russia were preserved as well. The merchants of Novgorod Republic established trade relations with the Hanseatic League, of which Riga was a member, and merchants through the Riga Merchant Guild. Nevertheless, Russian prospects for profit remained limited in the German-dominated trade league, including economic blockades preventing Novgorod from trading with Livonia. Circumstances changed in 1392, when under the "Nyborg agreement", it was agreed that German and Russian merchants would enjoy the freedom of movement. Russian trade contributed significantly to the development of Livonia over the following century. Regional power struggles In 1481, Ivan III of Russia briefly captured Dünaburg castle in southeastern Livonia in response to a Livonian attack on north-west Russia. During the Livonian War Russian tsar Ivan the Terrible captured several castles and towns in Eastern Latvia and held some of them even for 4 years. From the second half of the seventeenth century religiously repressed Old Believers from Russia settled in Latgale which was part of Polish–Lithuanian Commonwealth. In the 17th century, during Russo-Swedish War initiated by Alexis I of Russia, the Russians seized much of eastern Latgale, renamed Dünaburg into Borisoglebsk and controlled the region for 11 years between 1656 and 1667. Russia had to yield the area to Poland following the Treaty of Andrusovo. Consolidation under Russian rule Count Sheremetev's capture of Riga in the Great Northern War in 1710 completed Peter I's conquest