#include<stdio.h>

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