Math models of collective action explain why Ukraine is still fighting and why Iran might be headed for a revolution