import sys input = sys.stdin.readline l, r, m = map(int, input().split()) a, b = 1, 1 for i in range(1, min(m, l + 1)): a *= i; a %= m b *= a; b %= m ans = 0 for i in range(l, min(m, r + 1)): a *= i; a %= m b *= a; b %= m ans += b; ans %= m print(ans)