#include<stdio.h>
N=2*123456;
i,j,x,n,p;
int main(){int f[1+N];for(i=2;i<=N;++i)f[i]=1;for(i=2;i<N;++i)if(f[i])for(j=2;i*j<N;++j)f[i*j]=0;while(scanf("%d",&n)&&n){for(x=n+1;x<=2*n;++x){if(f[x])++p;}printf("%d\n",p);}return 0;}