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