#include <iostream>
using namespace std;
int pri[50001];

int b_search(int key,int p){
  int l = 0;
  int r = p;
  while(l < r){
    int c = (l + r)/2;
    if(key == pri[c]){cout << pri[c] << endl;return 1;}
    else if(key < pri[c])r = c;
    else l = c+1;
  }
  return 0;
}

int main(){
  int prime[50001];
  for(int i = 0 ; i < 50001 ; i++)prime[i] = 1;
  prime[0] = prime[1] = 0;
  for(int i = 2 ; i*i < 50001 ;i++ ){
    if(prime[i])for(int j = i*2 ; j < 50001 ;j+=i )prime[j] = 0;
  }

  int p = 0;

  for(int i = 0 ; i < 50001 ; i++){
    if(prime[i])pri[p++] = i;
  }

  int n;
  int chaek[50001];
  while( cin >> n,n ){
    for(int i = 0 ; i < 50001 ; i++ )chaek[i] = 1;
    int ret = 0;
    for(int i = 0 ; i < p ;i++){
      if(n - pri[i] > 0 && chaek[pri[i]] == 1){
	ret+= b_search(n - pri[i],p);
	chaek[n - pri[i]] = 0;
      }
    }
    cout << ret << endl;
  }
  return 0;
}