# -*- coding: utf-8 -*- N = int(input()) i = 3 while i*i<=N: if N%i == 0: break i += 1 print(i)