import sys sys.setrecursionlimit(500000) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) from collections import defaultdict,deque import bisect import itertools dic = defaultdict(int) d = deque() L,R,M = MI() ans = 0 count = 1 cc = 1 if M <= L: print(0) exit() for i in range(1,L+1): cc = (cc*i)%M count = (count*cc)%M ans = count for i in range(L+1,R+1): if i >= M: break else: cc = (cc*i)%M count = (count*cc)%M ans = (ans+count)%M print(ans)