import java.util.*; class B{ static Scanner s = new Scanner(System.in); public static void main(String[] args) { long in = s.nextLong(); if(in%3==0){ System.out.println(3); return; } if(in%4==0){ System.out.println(4); return; } if(in%2==0) in/=2; long l = (long)(Math.sqrt(in)+0.6); long c = 5; while(in%c!=0){ c+=2; if(c>l){ System.out.println(in); return; } } System.out.println(c); } }