The war was also expensive. In the 1650s, there were over 20,000 Spanish troops in Extremadura alone, compared to 27,000 in Flanders. Between 1649 and 1654, about 29 percent  of Spanish defence spending was appropriated for fighting Portugal, a figure that rose during the major campaigns of the 1660s. Portugal was able to finance its war effort because of its ability to tax the spice trade with Asia and the sugar trade from Brazil, and it received some support from the European opponents of Spain, particularly  France and England. The 1650s were indecisive militarily but important on the political and diplomatic fronts, with the brief exception of the Battle of the Lines of Elvas in 1659. The death of João IV in 1656 signalled the beginning of the regency of his wife, followed by a succession crisis and a palace coup . Despite these domestic problems, the expulsion of the Dutch from Brazil  and the signing of a treaty with England  improved Portugal's diplomatic and financial position temporarily and gave it needed protection against a naval raid on Lisbon. Nonetheless, the overriding goal, a formal pact with France continued to evade Portugal, whose weakness and isolation had been driven home by its virtual exclusion at the negotiations for the European settlement-of-settlements, the new realpolitik of the peace of Westphalia . With this treaty and the end of hostilities in Catalonia in 1652, Spain was again ready to direct its efforts against Portugal, but it faced a lack of men, resources, and, especially, good military commanders.. How many years after the The death of João IV was the Battle of the Lines of Elvas?