def solve(): from math import sqrt n = int(input()) x = 3 while x <= sqrt(n): if n % x == 0: print(x) return x += 1 print(int(n / 2) if n % 2 == 0 and n > 4 else n) solve()