'use strict';
(function(input){
  const numList=new Array(320).fill(0).map((x,i)=>i);
  numList[0]=numList[1]=Infinity;
  for(let k=0;k<1024;k++){
    let l=2;
    while(numList[k]*l<1024){
      numList[k*l]=Infinity;
      l++;
    }
  }
  const primeList=numList.filter(x => x<2048);
  const isPrime= x=>primeList.some(y=>y===x)||primeList.reduce((acc,cur)=>x%cur===0||acc,false);
  
  let X=input.trim()-0;
  
  while(!isPrime(X)){
    X++;
  }
  
  console.log(X);
})(require('fs').readFileSync('/dev/stdin','utf8'));
