#include <iostream>
using namespace std;
int main(){
	int i,j,n,p[123457*2]={0};
	char buf[120], p;
	for(i=2;i<123457;i++) if(!p[i]) for(j=i*2;j<123457*2;j+=i) p[j]=1;
	for(i=2;i<123457*2;i++) p[i]=p[i-1]+!p[i];
	while(cin>>n,n) cout << p[2*n+1] - p[n] << endl;
	return 0;
}