#include<stdio.h>

int prime[200000]={},num[250000]={};
int main(void){
	int i,j,a,k=0,N,count;
	prime[k++]=2;
	prime[k++]=3;

	for(i=5;i<250000;i+=2){
		int flag=0;
		for(j=0;i>=prime[j]*prime[j];j++){
			if(i%prime[j]==0){
				flag=1;
				break;
			}
		}
		if(flag==0){prime[k++]=i;}
	}

	
	
	for(i=0;i<k;i++){
		a=prime[i];
		num[a]=1;
	}

	
		while(1){
		scanf("%d",&N);
		if(N==0){break;}
		count=0;
		for(i=N+1;i<=2*N;i++){
			count+=num[i];
		}

		printf("%d\n",count);

	}
	return 0;
}