import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int x=scan.nextInt();
    int Ans=0, x1=0;
    boolean flag=false;
    if(x==2){
      Ans=2;
      flag=true;
    }else if(x%2==0){
      x1=x+1;
    }else{
      x1=x;
    }
    while(!flag){
      for(int a=2; a<x1; a++){
        if(x1%a==0){
          flag=true;
        }
      }
      if(!flag){
        Ans=x1;
        flag=true;
      }else{
        flag=false;
      }
      x1+=2;
    }
    System.out.println(Ans);
  }
}
/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