#include <stdio.h>

#define MAX_N 246912

int isPrime[ MAX_N + 1 ];

int main( void ) {
	int i, j, n, num;

	isPrime[ 0 ] = isPrime[ 1 ] = 0;
	for ( i = 2; i <= MAX_N; i++ )
		isPrime[ i ] = 1;

	for ( i = 4; i <= MAX_N; i += 2 )
		isPrime[ i ] = 0;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( ; scanf( "%d", &n ), n; printf( "%d\n", num ) ) {
		num = n == 1;
		for ( i = ( n + 1 ) / 2 * 2 + 1; i <= n * 2; i += 2 )
			num += isPrime[ i ];
	}

	return 0;
}