import math def seisuwa(N): M = N * (N - 1) // 2 Nl = [] for i in range(1, int(math.sqrt(N)) + 1): if N % i == 0: Nl.append(i) Nl.append(N // i) Nl = sorted(Nl) for j in range(1, len(Nl) + 1): if M % Nl[-j] == 0: ans = Nl[-j] break return ans def main(): N = int(input()) print(seisuwa(N)) if __name__ == '__main__': main()