#include <bits/stdc++.h>
using namespace std;
int main() {
  int x = 0, a;
  while (cin >> x) {
    int y = sqrt(x) + 1;
    a = 0;
    for (int i = 2; i < y; i++) {
      if (x % i == 0) {
        a = 1;
        break;
      }
    }
    if (a == 0) x++;
  }
  cout << x << endl;
  return 0;
}
