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