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

int main(void)
{
  
  int num;
  int result = 0;
  int i,j;
  int sqr;

  while(1){
    
    scanf("%d",&num);
    if(num == 0)
      break;
    
    for(i = num+1;i <= (2*num);i++){
      if(i == 2){
	result++;
	continue;
      }
      else if(i < 2 || (i % 2) == 0)
	continue;

      sqr = sqrt(i);
      for(j = 3;j < sqr ;j = j + 2){
	if((i % j) == 0)
	  break;
      }

      if((i % j) == 0)
	continue;
      
      result++;
    }
    
    printf("%d\n",result);

    result = 0;
    
  }

  return 0;
}
    