Charles's retreat from Jarosław to Warsaw almost ended with disaster, for he returned with the fragments of his host, for his army was trapped by the Polish-Lithuanian armies – amidst three converging armies, in a marshy forest region intersected in every direction by well-guarded rivers – is considered one of his most brilliant achievements. But on 21 June 1656 the Poles retook Warsaw, and four days later Charles was obliged to purchase the assistance of Frederick William I, by the treaty of Marienburg (23 June 1656). On 28–30 July the combined Swedes and Brandenburgers, 18,000 strong, after a three days’ battle, defeated John Casimir's army of 40,000 at Warsaw, however the Polish-Lithuanian forces promptly withdrew with no large losses and apparent strong will to fight another day, while Swedish host reoccupied the Polish capital again, causing much destruction to the city and its inhabitants. However, this feat of arms did not have the desired result for Charles, and when Frederick William compelled the Swedish king to open negotiations with the Poles, they refused the terms offered, the war resumed, and Charles concluded an offensive and defensive alliance with the elector of Brandenburg (Treaty of Labiau, 20 November 1656) which stipulated that Frederick William and his heirs should henceforth possess the full sovereignty of East Prussia.