#include <stdio.h>
#include <math.h>

int primes[78498], primepis[1000000], num_primes;
int calculated;
int main() {
	primes[0] = 2;
	primepis[2] = 1;
	calculated = 2;
	num_primes = 1;
	for (int i = 3; i <= 999999; i += 2) {
		bool is_prime = true;
		int max = (int)(sqrt(i)) + 1;
		for (int j=1; primes[j] < max && j<num_primes; j++) {
			if (i%primes[j] == 0) {
				is_prime = false;
				break;
			}
		}
		if (is_prime) {
			primes[num_primes++] = i;
			primepis[i] = primepis[i + 1] = primepis[i - 1] + 1;
		}
		else {
			primepis[i] = primepis[i + 1] = primepis[i - 1];
		}
	}
	while (true) {
		int n;
		if (!scanf("%d", &n)) break;
		printf("%d\n", primepis[n]);
	}
}
