/*
AizuOnline A1172
Title Chebyshev's Theorem
*/
#include <stdio.h>
#define MAXVAL 123456*2
#define TOCHUU 50000
int cnt;

int prime_f[MAXVAL];

int prime_table[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,
		   53,59,61,67,71,73,79,83,89,97,
		   101,103,107,109,113,127,131,137,139,149,151,157,163,
		   167,173,179,181,191,193,197,199,211,223};
//
int next_prime(int n)
{
  int i;

  for(i=n+1;i<MAXVAL;i++)
    if(prime_f[i])
      return(i);
}
void make_furui()
{
  int i,j,p;

  prime_f[0]=prime_f[1]=0;
  for(i=2;i<=MAXVAL;i++)
    prime_f[i]=1;
  for(i=0;i<sizeof(prime_table)/sizeof(int);i++)
    {
      p = prime_table[i];
      for(j=2;p*j<=MAXVAL;j++)
	prime_f[p*j]=0;
    }
  
  for(i=223;i*i<MAXVAL;)
    {
      i=next_prime(i);
      for(j=2;i*j<=MAXVAL;j++)
	prime_f[i*j]=0;
	}
}
int prime_n2n(int n)
{
  return(prime_f[2*n]-prime_f[n]);
}
void make_runsum()
{
  int i;

  for(i=1;i<=MAXVAL;i++)
    prime_f[i] += prime_f[i-1];
}
void show_runsum()
{
  int i;

  for(i=1;i<30;i++)
    printf("%d:",prime_f[i]);
  printf("\n");
}

main()
{
  int N;

  make_furui();
  make_runsum();

  
  while(EOF != scanf("%d",&N) && N)
    {
      printf("%d\n",prime_n2n(N));
      //printf("%d\n",prime_f[N]);
      //printf("%d\n",prime_f[2*N]);
    }
return(0);
}