
#include <stdio.h>
#include <math.h>

int main (){

	int count=0;
	int point[10000]={};
	int max=0;

	int result[1000]={};
	int prime[1000000]= {};
	int sq_num=0;
	int deli=0;
	int i=0;

	//??\???
	while(1){
		scanf("%d",&point[count]);
		if(point[count] == 0 ){
			break;
		}
		count++;
	}
	//printf("count:%d\n",count );

	count=0;
	while(1){

		//??¨??¨???1???
		prime[2]=1;
		i=3;
		while(1){
			prime[i]=1;
			i++;
			prime[i]=0;
			i++;
			if( i > 1000000){
				break;
			}
		}

		
		i=point[count];
		sq_num = (int)sqrt(2*i);
		//printf("sq:%d\n",sq_num );
		i=2;	
		while(1){

			//printf("i:%d\n",i );
			
			if(prime[i]==1){
				deli=i;
				
				while( point[count]*2 > deli ){
					deli += i;
					//printf("deli:%d\n",deli );
					prime[deli] = 0;

				}

			}
			i++;

			if(sq_num < i){
				break;
			}

		}

		/*
		i=0;
		while(i< 102){
			//printf("prime i:%d  %d \n",i,prime[i]);
			i++;
		}
		*/
		

		//printf("point is:%d\n",point[count]);
		i=point[count];
		i++;
		while(1){
			if(prime[i] == 1){
				
				result[count]++;
			}
			i++;
			
			if (2*point[count] < i){
				break;
			}
		}
		
		//printf("result:%d\n",result[count] );
		if(point[count] == 0 ){
		//printf("input finish\n");
			break;
		}
		printf("%d\n",result[count]);
		count++;

		


	}

	//??????
	/*
	i=0;
	while(count > i){
		printf("res:%d,%d\n",i,result[i] );
		i++;
	}
	*/

	return 0;
}