import sys input = sys.stdin.readline l, r, m = map(int, input().split()) if(l >= m): print(0) exit(0) r = min(r, m - 1) 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 + 1): a *= i; a %= m b *= a; b %= m ans += b; ans %= m print(ans)