#include <iostream>

#define MAX_N 999999

unsigned long long int n;
bool cache[MAX_N+1];

void make_cache(void)
{
    for (int i = 0; i <= MAX_N; i++) {
        cache[i] = true;
    }

    for (int i = 2; i <= MAX_N; i++) {
        if (cache[i]) {
            for (int j = i + i; j <= MAX_N; j += i) {
                cache[j] = false;
            }
        }
    }
}

void solve(void)
{
    int count = 0;
    for (int i = 2; i <= n; i++) {
        if (cache[i]) count++;
    }
    std::cout << count << std::endl;
}
        

int main(void)
{
    make_cache();
    while (std::cin >> n) {
        if (n == 0) break;
        solve();
    }
    return 0;
}