a[1<<20];
n=1<<20;
main(i,c){
	*a=a[1]=1;
	for(;++i<n;)
		if(!a[i])
			for(c=1;++c*i<n;)
				a[i*c]=1;
	for(;scanf("%d",&n),n;){
		c=0;
		for(i=n;++i<=2*n;)
			!a[i]&&c++;
		printf("%d\n",c);
	}
	exit(0);
}