def solve(L: int, R: int, M: int) -> int: if M <= L: return 0 factorial = 1 factorial_cumprod = [1] * M for i in range(1, M): factorial *= i factorial %= M factorial_cumprod[i] = factorial_cumprod[i - 1] * factorial factorial_cumprod[i] %= M res = 0 for n in range(L, min(R + 1, M)): res += factorial_cumprod[n] res %= M return res print(solve(*map(int, input().split())))