#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int i,j;
  bool check[50005]={};
  int prime[5200]={};
  int num=0;

  for(i=2;i<50005;i++){
    if(check[i]==true)continue;
    prime[num]=i;
    num++;
    for(j=2;i*j<50005;j++)
      check[i*j]=true;
  }
 
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int sum=0;

    for(i=0;prime[i]<n;i++)
      for(j=i;prime[i]+prime[j]<n+1;j++){
	if(prime[j]+prime[i]==n){
	  sum++;
	  break;
	}
      }

    cout<<sum<<endl;
  }
}