#include<stdio.h>
#include<stdlib.h>
int main(int argc, char *argv[])
{
  while(1){
    int x, n;
    int res = 0;

    scanf("%d", &n);
    if( n == 0 ) break;
    
    for(x = n+1; x <= 2*n; ++x){
      int is_x_prime = 1;
      for(i = 2; i < x; ++i){
        if( x % I == 0 ){
          is_x_prime = 0;
        }
      }
      if( is_x_prime ) ++res;
    }

    printf("%d\n", res);
  }
  return (EXIT_SUCCESS);
}