# YOU ARE GIVEN TWO INTEGERS N AND M. # YOUR TASK IS TO FIND THE FACTORIAL OF N, MODULO M. import math n,m = map(int,input().split()) print(math.factorial(n) % m)