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

int main (){

	int count=0;
	int input;
	int max=0;

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

	//??\???
	while(1){
		scanf("%d",&input);
		if(input == 0 ){
			break;
		}
		count = 0;

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

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

				}

			}
			i++;

			if(sq_num < i){
				break;
			}

		}

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

		result = 0;




	}
	

	return 0;
}