n=int(input()) a=1 b=10**12 c='0'*12 if n<50: for i in range(1,n+1):a=a*i%b;c=a if n>15:c=(c+str(a))[-12:] print(c)