import sys sys.setrecursionlimit(10**9+1) N,M = map(int,input().split()) def factorial_(a): if a==0: return 1 return (a*factorial(a-1))%M from math import factorial print(factorial(N)%M)