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

int main(void)
{
  int i,j,k;
  int n,count;
  // printf("2 ");
  while(1){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    if(n%2!=0){
      n++;
    }
    count=0;
    for(i=n+1;i<=n*2;i+=2){
      k=0;
      for(j=3;j<=i-1;j+=2){
	//printf("%d %d %d\n",i,j,i%j);
	if(i%j==0){
	  //printf("%d ",i);
	    k=1;
	    break;
	}
      }
      if(k==0)
	count++;
    }
    printf("%d\n",count);
  }
  return 0;
}