#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

constexpr ll NOT_SPECIFIED_VALUE_MIN = INT64_MIN;
constexpr ll NOT_SPECIFIED_VALUE_MAX = INT64_MAX;

template <typename T>
vector<bool> eratosthenes(T n) {
	vector <bool> IsPrime;
	if (n + 1 > IsPrime.size()) {
		IsPrime.resize(n + 1, true);
	}
	IsPrime[0] = false;
	IsPrime[1] = false;

	for (T i = 2; i*i <= n; i++) {
		if (IsPrime[i]) {
			for (T j = 2; i*j <= n; j++) {
				IsPrime[i*j] = false;
			}
		}
	}
	return IsPrime;
}

int main() {
	vector<bool> isPrime = eratosthenes(1LL << 20);
	vector<ll> numPrime((1LL << 20) + 1, 0);
	ll now = 0;
	for (ll i = 1; i <= (1LL << 20); i++) {
		if (isPrime[i] == true) {
			now++;
		}
		numPrime[i] = now;
	}

	ll n;
	n = -1;
	while (true) {
		cin >> n;
		if (n == -1)break;
		cout << numPrime[n] << endl;
		n = -1;
	}


}

