n = int(input()) s = n * (n + 1) // 2 while n > 1: if s % n == 0: break n -= 1 print(n)