def compute_factorial_mod(N): mod_10e12 = 10 ** 12 total_2 = 0 total_5 = 0 # Step 1: Count the number of 2s and 5s in N! for i in range(1, N + 1): x = i while x % 2 == 0: total_2 += 1 x //= 2 while x % 5 == 0: total_5 += 1 x //= 5 k = min(total_2, total_5) if k >= 12: return 0 remaining_2 = total_2 - k remaining_5 = total_5 - k required_mod = 10 ** (12 - k) # Step 2: Compute the product of rest (without 2 and 5) modulo required_mod rest_product = 1 for i in range(1, N + 1): x = i # Remove all factors of 2 and 5 while x % 2 == 0: x //= 2 while x % 5 == 0: x //= 5 rest_product = (rest_product * x) % required_mod # Step 3: Multiply by remaining 2^remaining_2 and 5^remaining_5 rest_product = (rest_product * pow(2, remaining_2, required_mod)) % required_mod rest_product = (rest_product * pow(5, remaining_5, required_mod)) % required_mod # Step 4: Multiply by 10^k and return mod 10^12 result = (rest_product * (10 ** k)) % mod_10e12 return result # Read input and output the result N = int(input()) print(f"{compute_factorial_mod(N):012d}")