import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(input()) def make_divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] candidates = make_divisors(N) candidates.sort() lis = set() for first in candidates: koho = make_divisors(N-first) for k in koho: lis.add(k) lis = list(lis) lis.sort() for c in lis[1:]: base = N lis = [] while base>0: if lis and base%c!=lis[-1]: break lis.append(base%c) base //= c if base==0: print(c) exit()