#include<stdio.h>

int main(){
  int i,j,n,yakusu=0,count,a=0;

  while(1){
    count=0;
    scanf("%d",&n);
    if(n==0)break;
    if(n%2==0){n++;a=1;}
    for(i = n+1-a; yakusu=0, i <= (n-a)*2; i += 2){
      for(j = 2; j < n+1-a; j++){
	if(i%j == 0){yakusu++; break;}
      }
      if(yakusu == 0)count++;

     }
    printf("%d\n",count);
  }
}