#include<iostream>
using namespace std;
int main() {
  int X;
  cin >> X;
  int ans = X;
  primecheck:
  for (int i = 2;i * i <= ans;++ i) {
    if (ans % i == 0) {
      ++ ans;
      goto primecheck;
    }
  }
  cout << ans;
}