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