#include <stdio.h>

int main(void){
    int n, i, j, p, s[247000];
    n=1;
    s[0]=0; s[1]=0;
    for (i=2; i<=246999; i++) {
        p=1; j=2;
        while (j*j<=i) {
            if (i%j==0) {
                p=0;
                break;
            }
            j++;
        }
        s[i]=s[i-1]+p;
    }
    while (1) {
        scanf("%d", &n);
        if (n==0) break;
        printf("%d\n", s[2*n]-s[n]);
    }
    return 0;
}
