On 25 June 1656, Charles X Gustav signed an alliance with Brandenburg: the Treaty of Marienburg granted Greater Poland to Frederick William in return for military aid. While the Brandenburgian elector was free of Swedish vassalage in Greater Poland, he remained a Swedish vassal for the Duchy of Prussia. Brandenburgian garrisons then replaced the Swedish ones in Greater Poland, who went to reinforce Charles X Gustav's army. On 29 June however, Warsaw was stormed by John II Casimir, who had drawn up to Charles X Gustav with a force of 28,500 regulars and a noble levy of 18,000 to 20,000. Thereupon, Brandenburg actively participated in the war on the Swedish side, prompting John II Casimir Vasa to state that while his Tartars already had the Swedes for breakfast, he would now take Frederick William into custody, where neither sun nor moon would shine. Already in May 1656, Alexis of Russia had declared war on Sweden, taking advantage of Charles being bound in Poland, and Livonia, Estonia and Ingria secured only by a Livonian army of 2,200 infantry and 400 dragoons, Magnus de la Gardie's 7,000 men in Prussia, and 6,933 men dispersed in garrisons along the Eastern Baltic coast. Alexis invaded Livonia in July with 35,000 men and took Dünaburg.. Who declared war on Sweden?