#include<cstdio>
#include<string.h>

int main(){
    int n,i;
	int p[50002];
	memset(p,1,50001),p[1]=0;
    for(i=2;i<50001;i++)if(p[i])for(n=i*2;n<50001;n+=i)p[n]=0;

    for(;n=0,scanf("%d",p);printf("%d\n",n))
		for(i=2;i<=n/2;++i)
			if(p[i]&&p[*p-i])n++;
}