#include <iostream>
using namespace std;

main(){
  int i,j,n[50000],a,ans;

  n[0] = 0;
  n[1] = 0;
  for(i=2;i<50000;i++) n[i] = 1;
  for(i=2;i<25000;i++){
    if(n[i] == 1){
      for(j=i*2;j<50000;j+=i) n[j] = 0;
    }
  }

  while(1){
    cin >> a;
    ans = 0;
    if(a == 0) break;
    for(i=2;i*2<=a;i++){
      if(n[i] == 1 && n[a-i] == 1) ans++;
    }
    if(a%2 == 0) cout << ans << endl;
    else cout << "0" << endl;
  }
  return 0;
}