#include <stdio.h>

int main(){
	int sosuu[1000000] = { 2, 3, 5 }, i,x,y=3,n;

	for (i = 3; i < 1000000; i+=2){
		for (x = 0; x < y;x++){
			if (i % sosuu[x] == 0){ break; }
			if (x+1 == y){ sosuu[y] = i, y++; }
		}
	}

	while (scanf("%d",&n)!= EOF){
		for (i = 0; i < y; i++){
			if (sosuu[i] < n + 1)break;
		}
	}
	return 0;
}