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