L, R, M = map(int, input().split()) if L >= M: print(0) exit() R = min(R + 1, M) a, b = 1, 1 for i in range(2, L): a *= i a %= M b *= a b %= M ans = 0 for i in range(L, R): a *= i a %= M b *= a b %= M ans += b ans %= M print(ans)