#include <stdio.h>

int main(void) {
	int pl[262144] = {0},c,i,j,n;
	pl[2] = 1;
	for(i = 3;i <= 262143;i+=2){
		pl[i] = 1;
	}
	for(i = 3;i <= 599;i+=2){
		if(pl[i]){
			for(j = 3*i;j <= 262143;j+=(2*i)){
				pl[j] = 0;
			}
		}
	}
	
	while(scanf("%d",&n) , n != 0){
		c = 0;
		for(i = n+1;i <= 2*n;i++){
			c+=pl[i];
		}
		printf("%d\n",c);
	}
	return 0;
}