n = int(input()) ans = n for i in range(n-1): ans = (ans * (n-1))%(10**12) n = n-1 if ans == 0: print("000000000000") break elif n == 1: print(ans)