// Aizu 1172: Chebyshev's Theorem
// 2017.9.13 bal4u@uu

#include <stdio.h>

#define MAX  250000
#define SQRT 500     // sqrt(MAX)
char prime[MAX + 5], *p, *q, *pmax = prime + MAX;

void mkprime()
{
	int k;
	prime[1] = 1; prime[2] = 0;
	for (k = 3, p = prime + 3; k <= SQRT; k += 2, p += 2)
		if (!*p) for (q = p + k; q <= pmax; q += k) *q = 1;
}

int main()
{
	int n, i, m, ans;

	mkprime();
	while (scanf("%d", &n) && n) {
		m = n << 1, ans = 0; if (n == 1) ans++;  // for 2
		i = n + 1; if (!(i & 1)) i++;            // for odd num only
		for ( ; i <= m; i += 2) if (!prime[i]) ans++;
		printf("%d\n", ans);
	}
	return 0;
}