//  #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432
#include <iostream>

using namespace std;

int main() {
  bool bj[110];
  bj[0] = 1;//--------打表
  bj[1] = 1;
  bj[2] = 1;
  bj[3] = 1;
  bj[5] = 1;
  bj[7] = 1;
  bj[11] = 1;
  bj[13] = 1;
  bj[17] = 1;
  bj[19] = 1;
  bj[23] = 1;
  bj[29] = 1;
  bj[31] = 1;
  bj[37] = 1;
  bj[41] = 1;
  bj[43] = 1;
  bj[47] = 1;
  bj[53] = 1;
  bj[59] = 1;
  bj[61] = 1;
  bj[67] = 1;
  bj[71] = 1;
  bj[73] = 1;
  bj[79] = 1;
  bj[83] = 1;
  bj[89] = 1;
  bj[97] = 1;
  bj[101] = 1;
  bj[103] = 1;
  int x;
  cin >> x;
  for (int i = x; i <= 2 * x; i++){
    if (bj[i]);
    else{
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
// 64 位输出请用 printf("%lld")