#coding: utf-8 #yuki_312 def prime_decomp(n): i = 2 table = [] while i * i <= n: while n % i == 0: n /= i table.append(i) i += 1 if n > 1: table.append(n) return table n=int(raw_input()) s=prime_decomp(n) if s[-1]==2: print 4 elif s[0]==2 and s[1]==2: if s[2]<4: print 3 else: print 4 elif s[0]==2: i=0 while s[i]==2: i+=1 continue print s[i] else: print s[0]