import math n, m = map(int, input().split()) x = math.factorial(n) % m print(x)