import java.util.Scanner; public class Main{ static boolean ip(int x){ if(x<=3) return true; else{ for(int i=2;i*i<=x;i++){ if(x%i==0) return false; } return true; } } public static void main(String[] args){ Scanner sc=new Scanner(System.in); while(sc.hasNext()){ int n=sc.nextInt(); for(int i=n-100;i<=n+100;i++){ if(!ip(i)){ System.out.println(i); break; } } } } }