import math n,m = map(int, input().split()) if n % m == 0: print(0) else: print(math.factorial(n % m))