#include <stdio.h>
#include <stdlib.h>

int main(void){
    long i, j, n;
    int *a;

    while(1){
        scanf("%ld", &n);
        if (n == 0){
            break;
        }
        a = malloc((2*n+1) * sizeof(int));

        if (a == NULL){
            printf("Insufficient memory.\n");
            exit(1);
        }

        for (i = 2; i <= 2*n; i++){
            a[i] = 1;
        }

        for (i = 2; i <= 2*n; i++){
            if (a[i] == 1){
                for (j = i; i * j <= 2*n; j++){
                    a[i*j] = 0;
                }
            }
        }

        long count = 0;
        for (i = n+1; i <= 2*n; i++){
            if (a[i] == 1){
                count++;
            }
        }
        printf("%ld\n", count);

        free(a);

    }

    return 0;
}
