#include <stdio.h>
#define N (246912)

int main(void){

  int n;
  int count;
  int a[N+1];
  unsigned int i;
  int k;

  for(i=1;i<=N;i++){
    a[i]=1;
  }

  a[1]=0;
  k=2;

  do{
    if(a[k]!=0){
      for(i=k*k;i<=N;i+=k){
	a[i]=0;
      }
    }
    k++;
  }while(k<=N);

  for(i=1;i<14*2;i++){
    printf("a[%d]%d\n ",i,a[i]);
  }

  printf("\n");


  while(1){
    scanf("%d",&n);
    if(n==0){
      break;
    }
  
    for(i=n+1,count=0;i<=2*n;i++){
      if(a[i]==1)
	count++; 
    }

    printf("%d\n",count);

  }

  return 0;

}  

  