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