#include<stdio.h>

int main(void){
  int n,i,j;
  int count;

  while(1){
    scanf("%d",&n);
    if(n==0) break;

    count=0;
    for(i=n+1;i<=2*n;i++){
      for(j=2;j*j<=i;j++){
        if(i%j==0) break;
      }
      if(j*j>i) count++;
    }
    printf("%d\n",count);
  }
  return 0;
}
