p = 4 * s * (s - 1) / 2 + s * (2 * r + 1)