An Equation for Resilience