#include<stdio.h>
int main(void){
  int i, j, n, so[246913], count;
  for(i=0;i<246913;i++){
    so[i]=1;
  }
  for(i=2;i<246913;i++){
    for(j=2;j<246913;j++){
      if(i*j<246914){
        so[i*j]=0;
      }else{
        break;
      }
    }
  }
  scanf("%d", &n);
  while(n!=0){
    count=0;
    for(i=n+1;i<2*n+1;i++){
      if(so[i]==1){
        count++;
      }
    }
    printf("%d\n", count);
    scanf("%d", &n);
  }

  return 0;
}