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

  return 0;
}