import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.System.in; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); int N = Integer.parseInt(reader.readLine()); int compositeNumber = 0; for (int i = N - 100; i <= N + 100; i++) { for (int j = 2; j * j <= i; j++) { if (i % j == 0) { compositeNumber = i; } } } System.out.println(compositeNumber); } }