N = int(input()) if N >= 673: print(0) else: result = 1 for i in range(2, N + 1): result = (result * i) % 2019 print(result)