#include<stdio.h>
#include<math.h>

int prime(int n, int m) {
	int count=0;
	int i,j,flag;

	for(i=n+1;i<=m;i++){
		flag = 1;
		if(i==2||i==3)
			count++;
		else{
			for(j=2;j<=sqrt(i);j++) {
				if(i%j==0) {
					flag=0;
					break;
				}
			}
			if(flag) 
				count++;
		}
	}
	return count;
}

int main() {

	int n;
	int Answer[10000],a=0;
	int i;

	for(;;) {
		scanf("%d",&n);
		if(n==0)
			break;
		Answer[a]=prime(n,2*n);
		a++;
	}

	for(i=0;i<a;i++)
		printf("%d\n",Answer[i]);
	return 0;
}