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