void main(){int i,j,n=1<<18;char p[1<<18];for(i=0;i<n;i++)p[i]=(i<2)?0:1;for(i=2;i*i<n;i++)for(j=i*2;j<n;j+=i)p[i]?p[j]=0:0;for(;j=0,scanf("%d",&n),n;printf("%d\n",j))for(i=n+1;i<=2*n;i++)p[i]?j++:0;}