#include "bits/stdc++.h"
using namespace std;
int main() {
	int X;
	cin >> X;
	int N = X, sum = 0;
	while (true) {
		sum = 0;
		for (int i = 1; i <= sqrt(N); i++) {
			if (N % i == 0) sum += 2;
		}
		if (sum == 2) {
			cout << N << endl;
			return 0;
		}
		N++;
	}
}
