Spain’s long-stalled politics just got moving again with acting Prime Minister Pedro Sanchez’s decision to seal a pact with his erstwhile foe Pablo Iglesias to form a government.

It was a big climb down for Sanchez, who as recently as September was saying he wouldn’t be able to sleep easy with members of Iglesias’s Podemos party in his administration because of their disputes over how to deal with Catalan separatism. Any lingering animosity between them notwithstanding, the math also looks tricky. Sanchez will still have to scour the new parliament for votes to make the deal work.

Perhaps for that reason, the text of the accord looks tilted toward pleasing all possible backers of their planned progressive government.

There’s a pledge to press for dialog over Catalonia -- a gesture to the Catalan separatist Esquerra Republicana party whose 13 deputies may need to sign off on the agreement. As talks continue, the volatile politics of the region could condition the support of the potential partners.

There’s also a promise to tackle rural exodus -- a wink at the tiny Teruel Existe group that won its first parliamentary seat on a campaign to address precisely that issue.

Here’s a guide on what may happen next, what the obstacles are and how the numbers might add up:

• What happens next?

• The new parliament will be constituted on Dec. 3. Once King Felipe VI holds consultations on candidates, votes to confirm the new prime minister’s appointment could take place after about two weeks. If all goes well for Sanchez, he could become head of a new government by Christmas, according to a timetable choreographed by the Constitution.

• How would the voting work?

• Sanchez has some time to explore support for his new government. The earliest date for an investiture vote would be about a fortnight after parliament is constituted. In the first round vote, Sanchez would need to win an absolute majority, that’s to say the support of 176 deputies in the 350-seat lower house. If he fails in that first attempt, a second vote would take place 48 hours later. To win that, he would need a simple majority among those who vote.

• How do the numbers add up?

• The political math appears to back the Sanchez-Iglesias project -- but only just. They could, for instance, get the support of the far-left party Mas Pais, the Basque nationalist party PNV, and three tiny regional parties. That would give them 168 lawmakers in favor. The duo would then need the Catalan separatists of Esquerra Republicana and two other regional groups to abstain. That would give Sanchez more votes in favor than against in a second-round vote.

• What have potential partners said so far?

• The Basques have already said their party will be “constructive” in helping Sanchez and Iglesias form a government. Leaders for the Catalan separatists have said they don’t currently support the pact but have indicated they are open to negotiating and lawmakers expect them to ultimately at least abstain.

• What happens if the numbers don’t add up?

• It’s back to the drawing board. If Sanchez fails to form a government, he -- or someone else -- gets to try again. If there’s still no majority within two months of the first investiture vote, the King dissolves parliament and calls new elections.

(Updates from fourth bullet point with party reactions.)

To contact the reporters on this story: Charles Penty in Madrid at cpenty@bloomberg.net;Jeannette Neumann in Madrid at jneumann25@bloomberg.net

To contact the editors responsible for this story: Chad Thomas at cthomas16@bloomberg.net, ;Ben Sills at bsills@bloomberg.net, Raymond Colitt

©2019 Bloomberg L.P.