import java.io.BufferedReader; import java.io.InputStreamReader; public class No192 { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); int N = Integer.parseInt(br.readLine()); for (int i = N - 100; i < N + 100; i++) { if (i < 2) { i = 1; continue; } if (!isPrime(i)) { System.out.println(i); break; } } } catch (Exception e) { System.err.println("Error:" + e.getMessage()); } } static boolean isPrime(long n) { if (n < 2) { return false; } else if (n == 2) { return true; } if (n % 2 == 0) { return false; } for (int i = 3; i * i <= n; i += 2) { if (n % i == 0) { return false; } } return true; } }