import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.math;
import std.file;
  
int[] sosu() 
{
	const nmax = 999999;
	int m = nmax.to!double.sqrt.ceil.to!int;
	//int m = to!int(ceil(sqrt(to!double(n))));
	auto list = new bool[nmax];
	list[] = true, list[0] = list[1] = false;
	int[] num;
	for (int i = 2; i < nmax;  i++)
	{
		if(list[i])
		{
			num ~= i;
			for (int j = i * 2; j < nmax; j += i)
			{
				list[j] = false;
			}
		}
	}
    return num;
}

void main()
{
	int n;
	int[] sosu = sosu();
	string l;
	while((l = readln()).length >= 2)
	{
		n = to!int(chomp(l));
		if(n<2)
		{
			writeln(0);
			continue;
		}
		foreach(int i; 0 .. n)
		{
			if(sosu[i] < n)
				continue;
			if(sosu[i] == n)
			{
				writeln(i + 1);
				break;
			}
			if(sosu[i] > n)
			{
				writeln(i);
				break;
			}
		}
	}
}
		