/*
 * Copyright (C) 2011 Hiroyasu Kamo
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * ACM-ICPC 2011 Japan Domestic Contest
 *  Problem A  Chebyshev's Theorem
 *
 *	Author: Hiroyasu Kamo <wd@ics.nara-wu.ac.jp>
 */

#include <numeric>
#include <iostream>
#include <vector>

#ifndef MAX_DATUM
#define MAX_DATUM	0xfffff
#endif

const std::vector<bool>
eratosthenes(long x)
{
	std::vector<bool>	tab(x + 1, true);
	tab[0] = false;
	tab[1] = false;
	for (long i = 2; i * i <= x; i ++) {
		for (long j = i * i; j <= x; j += i) {
			tab[j] = false;
		}
	}
	return tab;
}

const std::vector<long>
chebyshev(long x)
{
	static const std::vector<bool>	etab = eratosthenes(x * 2);
	std::vector<long>	tab;
	long	c = 0;
	tab.push_back(c);
	for (long i = 0, j = 0; i < x; ) {
		c += etab[++ j];
		c += etab[++ j];
		c -= etab[++ i];
		tab.push_back(c);
	}
	return tab;
}

int
main(int argc, char **argv)
{
	const	std::vector<long>	ctab = chebyshev(MAX_DATUM);
	for (long x; std::cin >> x && x > 0; ) {
		std::cout << ctab[x] << "\n";
	}
	return 0;
}
