#include<stdio.h>
#include<math.h>
int IsPrime(int n);
int main(){
  int n,i,j,count,ans[1000000];
  j=0;
  while(1){
    scanf("%d",&n);
    if(n==0)
      break;
    count=0;
    for(i=n;i<=2*n;i++){
      if(IsPrime(i)){
	count++;
      }
    }
    ans[j]=count;
    j++;
  }
  for(i=0;i<j;i++)
    printf("%d\n",ans[i]);
  return 0;
}

int IsPrime(int n){
  int i,limit;
  if(n==2)
    return 1;
  if(n<2 || n%2==0)
      return 0;
  limit = (int)sqrt((double)n);
  for(i=3;i<=limit;i+=2)
    if(n%i==0) return 0;
  return 1;
}