N,M = map(int,input().split()) import math as ma if N >= M: print(0) else: print(ma.factorial(N) % M)