
#include <stdio.h>
#define N 123456*2+5

int main(void){
    int a[N],i,j,l=1,count;
    
    for(i=0;i<N;i++)
        a[i]=1;
    a[0]=a[1]=0;
    for (i=2; i*i<N; i++) {
        if(a[i])
            for (j=i+i; j<N; j=j+i) {
                a[j]=0;
            }
    }
   
    
    while(1){
        scanf("%d",&l);
        if(l==0)break;
        
        count=0;
        for(i=l+1;i<=2*l;i++)
            if(a[i])
                count++;
        printf("%d\n",count);
    }
    
    return 0;
}