#include <stdio.h>

#define NUMBER_MAX (123456*2)

int sosuu_num[NUMBER_MAX+1];

void make_sosuu_num_list(void) {
	int i,j;
	for(i=0;i<=NUMBER_MAX;i++)sosuu_num[i]=1;
	sosuu_num[0]=sosuu_num[1]=0;
	for(i=2;i<=NUMBER_MAX;i++) {
		if(sosuu_num[i]) {
			for(j=i+i;j<=NUMBER_MAX;j+=i)sosuu_num[j]=0;
		}
	}
	for(i=1;i<=NUMBER_MAX;i++)sosuu_num[i]+=sosuu_num[i-1];
}

int main(void) {
	int n;
	make_sosuu_num_list();
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		printf("%d\n",sosuu_num[2*n]-sosuu_num[n]);
	}
	return 0;
}