
#include <iostream>
#include <cmath>
#include <vector>
#include <time.h>     // for clock()
using namespace std;

/*
1???2 ?????? n ?????§?????´??°???????????????
2??????????????£???????????°????????§???????°?????????????????????? p ??¨?????????????????????????????????????????°?????? p ??¨?????????
p ??\?????? p ????????°?????¨????¶????????????????
3???2??????????????°?????????????????????p ??? ???n ????¶??????????????????????????????????????????£?????????????´???°???
*/
// ??¨????????????????????????
int SieveOfEratosthenes(int num) {
	// num???????´???°?????°
	int count = 0;

	// Route Num?????´??°??¨??????????????????
	int routeN_int = (int)sqrt(num);
	//cout << routeN_int << endl;

	// ???n?????§?????´??°?????????????´???°????????°????????????
	//vector<bool> prime_flag_set(num + 1, true);
	vector<int> prime_flag_set(num + 1, 1);
	
	/*
	for (int i = 0; i < prime_flag_set.size(); i++) {
		prime_flag_set[i] = true;
	}
	*/
	
	//cout << endl;
	// 1???2 ?????? n ?????§?????´??°????????????p????????°????????? = false
	for (int p = 2; p < prime_flag_set.size(); p++) {
		if (prime_flag_set[p] == 0) {
			continue;
		}
		int j = 2;
		// 3???2??????????????°?????????????????????p ??? ???n ????¶????????????????
		while (p <= routeN_int) {
			if (p*j > num) {
				// num??\???
				break;
			}
			prime_flag_set[p * j] = 0;
			//p????????°????±???????
			j++;
		}
	}
	// 2??\???
	for (int i = 2; i < prime_flag_set.size(); i++) {
		if (prime_flag_set[i] == 1) {
			count++;
		};
		//cout << "Flag" << i << " " << prime_flag_set[i] << endl;
	}

	return count;
}

int main() {

	int num = 0;
	while (cin >> num, num != 0) {
		//clock_t start = clock();    // ??????????????????
		cout << SieveOfEratosthenes(num) << endl;
		//clock_t end = clock();     // ????????????
		//std::cout << "duration = " << (double)(end - start) / CLOCKS_PER_SEC << "sec.\n";
	}
	return 0;
}