import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a == 2){
            System.out.println(a);
            return;
        }
        ArrayList<Integer> list = getPrime(a);
        while(true){
            if(check(a,list)){
                System.out.println(a);
                return;
            }
            a++;
        }
    }
    
    static ArrayList<Integer> getPrime(int x){
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(2);
        int max = (int)Math.pow(x*2,0.5);
        for(int i = 3; i < max; i+=2){
            boolean chk = true;
            for(int j : list){
               if(i % j == 0){
                   chk = false;
                   break;
               }
            }
            if(chk){
                list.add(i);
            }
        }
        return list;
    }
    
    static boolean check(int x, List<Integer> list) {
        for(int j : list){
           if(x % j == 0){
               return false;
           }
        }
        return true;
    }
}


/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz