#include <stdio.h>
#define MAX (300000)

char prime[MAX + 1];

int main(void)
{
	int i, j;
	int n, num;
	
	prime[0] = prime[1] = 0;
	for (i = 2; i <= MAX; i++){
		prime[i] = 1;
	}
	
	for (i = 2; i * i <= MAX; i++){
		for (j = i * i; j <= MAX; j += i){
			prime[j] = 0;
		}
	}
	
	while (scanf("%d", &n), n){
		num = 0;
		i = n + 1;
		n *= 2;
		
		for (; i <= n; i++){
			if (prime[i]){
				num++;
			}
		}
		
		printf("%d\n", num);
	}
	
	return (0);
}