#include<stdio.h>

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

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