#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

#define PLIMIT 123456*2
int prime[PLIMIT+10];
int cum[PLIMIT+10];//閉区間
void makep(ll n){prime[0]=prime[1]=1;for(int i=2;i*i<=n;i++)if(!prime[i])for(int j=i*i;j<=n;j+=i)prime[j]=1;}

int main(){
	makep(PLIMIT);
	rep(i,1,PLIMIT+1)cum[i]=cum[i-1]+!prime[i];
	ll n;
	while(scanf("%lld",&n),n){
		printf("%lld\n",cum[2*n]-cum[n]);
	}
}
