#include <stdio.h>

#define N 246912

static
int erat[ N + 1 ] = { 0 };

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( j = 2; j <= N; ++j )
  {
    if ( erat[ j ] )  continue ;

    for ( i = j * 2; i <= N; i += j )
    {
      erat[ i ] = -1;
    }
  }

  j = 0;
  for ( i = 2; i <= N; ++i )
  {
    j += !( erat[ i ] );

    erat[ i ] = j;
  }

  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    printf ( "%d\n", erat[ n * 2 ] - erat[ n ] );
  }

  return ( 0 );
}