L, R, M = map(int, input().split()) if R >= M: print(0) else: fact = 1 mul = 1 answer = 0 for i in range(1, R + 1): fact = fact * i % M mul = mul * fact % M if i >= L: answer = (answer + mul) % M print(answer)