#include <iostream>
#include <cmath>
#define number 246912
#define MAX 246913
using namespace std;
int prime_num[MAX] = {
0,
};
void init()
{
prime_num[1] = 0;
for (int i = 2; i < MAX; i++)
prime_num[i] = i;
for (int i = 2; i <= sqrt(number); i++)
{
if (prime_num[i] == 0)
continue;
else
for (int j = i * i; j < MAX; j += i)
prime_num[j] = 0;
}
}
int main(void)
{
init();
int n;
while (cin >> n)
{
int count = 0;
if (n == 0)
break;
for (int i = (n + 1); i <= (2 * n); i++)
if (prime_num[i] != 0)
count++;
cout << count << '\n';
}
}
Coding/BaekJoon