import java.util.Scanner; class Main { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); int n = in.nextInt(); int a = n - 98; in.close(); while(true) { //Fermat test if((Math.pow(2, (a-1)) % a) != 1) { System.out.println(a); break; } else { a++; } } } }