from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline L,R,M = map(int,input().split()) if L>=M: print(0) exit() f = [1]*(M+1) for i in range(2,M+1): f[i] = i*f[i-1]%M s = 1 for i in range(1,L+1): s = (s*f[i])%M ans = s%M for i in range(L+1,min(M+1,R+1)): s = (s*f[i])%M ans = (ans + s)%M print(ans)