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

#define NUM 123456*2  // NUM??\???????´???°????±???????

int main(void)
{
  unsigned i, j;
  unsigned sq_num = (int)sqrt((double)NUM);
  unsigned prime[NUM];
  int count,n;
  // 1????????£???????????????????´???°
  // 0????????£??????????????????????????°????´???°??§????????????
  
  for (i = 0; i < NUM; i++)
    prime[i] = 1;  // ??¨????????°???1????????????
  prime[0] = 0;    // 1????´???°??§?????????

  for (i = 1; i < sq_num; i++) {
    if (prime[i] == 1)          // prime[i]????´???°??????
      for (j = (i+1); (i+1) * j <= NUM; j++)
	prime[(i+1) * j - 1] = 0;  // ?´???°????????°????´???°??§?????????
  }
  
  while(1){
    scanf("%d",&n);
    count=0;
    if(n==0){
      break;
    }
    for (i = n; i <=n*2; i++)
      if (prime[i] == 1)  // 1????????£???????????????????´???°
	count++;
    
    printf("%d\n",count);
  }
  return (0);
}