import math N,M = map(int,input().split()) print(math.factorial(N)%M)