institution of Ukraine at the time, to accommodate 2,000 students. In 1702, the Cossacks of Right-bank Ukraine, under the leadership of hetman Semen Paliy, began an uprising against Poland, which after early successes was defeated. Mazepa convinced Russian Tsar Peter I to allow him to intervene, which he successfully did, taking over major portions of Right-bank Ukraine, while Poland was weakened by an invasion of Swedish king Charles XII. The Great Northern War In the beginning of the 18th century, as the Russian Empire lost significant territory in the Great Northern War, Peter I decided to reform the Russian army and to centralize control over his realm. In Mazepa's opinion, the strengthening of Russia's central power could put at risk the broad autonomy granted to the Cossack Hetmanate under the Treaty of Pereyaslav in 1654. Attempts to assert control over the Zaporozhian Cossacks included demands of having them fight in any of the tsar's wars, instead of only defending their own land against regional enemies as was agreed to in previous treaties. Now Cossack forces were made to fight in distant wars in Livonia and Lithuania, leaving their own homes unprotected from the Tatars and Poles. Ill-equipped and not properly trained to fight on par with the tactics of modern European armies, Cossacks suffered heavy losses and low morale. The Hetman himself started to feel his post threatened in the face of increasing calls to replace him with one of the abundant generals of the Russian army. Change of sides The last straw in the souring relations with Tsar Peter was his refusal to commit any significant force to defend Ukraine against the Polish King Stanisław Leszczyński, an ally of Charles XII of Sweden, who threatened to attack the Cossack Hetmanate in 1708. Peter expected that king Charles of Sweden was going to attack and thought that he could spare no forces. In the opinion of Mazepa, this blatantly violated the Treaty of Pereyaslav, since Russia refused to protect Ukraine's territory and left it to fare on its own. As the Swedish and Polish armies advanced towards Ukraine, Mazepa allied with them on 28 October 1708. However, only 3,000 Cossacks followed their Hetman, with the rest remaining loyal to the Tsar. Mazepa's call to arms was further weakened by the Orthodox Clergy's allegiance to the Tsar. Learning of Mazepa's treason, the Russian army sacked and razed the Cossack Hetmanate capital