#include<stdio.h>
#define M 50000
int main(){
  int i,j,n,p[M]={1,1};
  for(i=3;i*i<M;i+=2){
    if(p[i])continue;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  while(scanf("%d",&n),n){
    for(i=j=3;i+i<=n;i+=2)j+=(1-p[n-i])*(1-p[i]);
    printf("%d\n",j-3);
  }
  return 0;
}