In the Treaty of Labiau on 20 November, Charles X Gustav of Sweden granted Frederick William of Brandenburg full sovereignty in the Duchy of Prussia in turn for a more active participation in the war. In the Treaty of Radnot on 6 December, Charles X Gustav promised to accept George II Rákóczi of Transylvania as king of Poland and Grand Duke of Lithuania in return for his entrance into the war. Rákóczi entered the war in January 1657, crossing into the commonwealth with a force of 25,000 Transylvanian-Wallachian-Moldavian men and 20,000 Cossacks who broke the Polish siege of Kraków before they met with Charles X Gustav, who had led a Swedish-Brandenburgian army southwards. The following month saw the Swedish-Brandenburg-Transylvanian-Romanian-Cossack forces play cat and mouse with the Polish-Lithuanian forces, moving about all of the commonwealth without any major engagements, except the capture of Brest by Charles X Gustav in May, and the sack of Warsaw by Rákóczi and Gustaf Otto Stenbock on 17 June. Due to internal conflicts within the Cossacks practically there was no participation of Cossack Hetmanate in that war. Worn out from previous campaigns and requesting Bohdan Khmelnytsky to break with Sweden, Alexis of Russia eventually signed the Truce of Vilna or Niemież with the Polish-Lithuanian Commonwealth, and did not engage the Swedish army in any major battle throughout 1657 even though he still reinforced his armies in Livonia. On 18 June, a Swedish force defeated a Russian army of 8,000 men commanded by Matvey V. Sheremetev in the Battle of Walk at Walk . In early 1658, Sweden and Russia agreed on a truce, resulting in the Treaty of Valiesar  and the Treaty of Kardis . The Russian war with Poland-Lithuania on the other hand resumed in 1658.
Which happened first, the capture of Brest or the sack of Warsaw?
capture of Brest