#include<stdio.h>
#include<string.h>

char so[1000001];

int main(){
	int n,i,j,count;
	memset(so,0,sizeof(so));
	so[1]=1;
	for(i=2;i<1000;){
		for(j=i;i*j<=1000000;j++){
			printf("%d %d\n",i,j);
			so[i*j]=1;
		}
	}
	count=0;
	while(0<=scanf("%d",&n)){
		for(i=2;2*i<=n;i++){
			if(so[i]==0 && so[n-i]==0)++count;
		}
		printf("%d\n",count);

	}
	return 0;
}