In 1699 Russia, Denmark and the Polish-Lithuanian Commonwealth with Saxony formed the Northern Alliance against Swedish supremacy in the Baltic. In 1700 the boy-king Charles XII of Sweden first knocked out the Kingdom of Denmark, then with 8,000 men shattered a Russian army of 40,000 at Narva; he turned into Poland and spent seven years hunting Augustus II — a deep and lonely campaign. Peter the Great used the respite to build his army and his fleet, taking the Neva mouth in 1703 to found Saint Petersburg; in 1708 he checked the Swedes at Lesnaya, and in 1709 at Poltava the Russian Empire annihilated the Swedish main army — Charles fled into Turkey and stayed five years before finding his way home. Denmark, Britain and Prussia entered the war in turn and Sweden's Baltic fortresses fell one by one; in 1718 Charles died in the trenches before Norway, and in 1721 the Treaty of Nystad closed the war: Russia gained Estonia, Livonia and the Karelian isthmus and took the imperial title, entering the ranks of the continental powers; Sweden lost its Baltic-eastern shore and its supremacy, sliding into the 'Age of Liberty' — the crown bound by constitution, the north's first constitutional order — and the north's center of power moved south.