In the middle of the 17th century Sweden was the third-largest country in Europe by land area, surpassed by only Russia and Spain. Sweden reached its largest territorial extent under the rule of Charles X after the treaty of Roskilde in 1658, following Charles X's risky but successful crossing of the Danish Belts. The foundation of Sweden's success during this period is credited to Gustav I's major changes to the Swedish economy in the 16th century, and his introduction of Protestantism. In the 17th century, Sweden was engaged in many wars, for example with the Polish–Lithuanian Commonwealth, with both sides competing for territories of today's Baltic states, with Sweden suffering a notable defeat at the Battle of Kircholm. One-third of the Finnish population died in the devastating Great Famine of 1695–1697 that struck the country. Famine also hit Sweden, killing roughly 10% of Sweden's population.