n = int(input()) a = 2019 while n != 0: a, n = n, a % n print(a)