function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	let X = parseInt(input[0][0], 10);
	let v_TF = Array.from({length: 1e5 * 2}, () => true);
	for (let i = 2; i <= Math.sqrt(1e5 * 2); i++){
		for (let j = 2; j <= 1e5*2 / i; j++){
			v_TF[i * j - 1] = false;
		}
	}
	let v_prime = [];
	for (let i = 1; i < v_TF.length; i++){
		if (v_TF[i]) v_prime.push(i + 1);
	}

	const lowerBound = (arr, n) => {
		let first = 0, last = arr.length - 1, middle;
		while (first <= last) {
			middle = 0 | (first + last) / 2;
			if (arr[middle] < n) first = middle + 1;
			else last = middle - 1;
		}
		return first;
	}

	console.log(v_prime[lowerBound(v_prime, X)]);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
