#include<iostream>
#include<cmath>
using namespace std;

#define M 50010

int main() {
  bool p[M];
  int sqM = (int)sqrt(M), n;
  for(int i=0; i<M; ++i) p[i] = true;
  p[0] = p[1] = false;
  for(int i=2; i<sqM+1; ++i) {
    if(p[i]) for(int j=i*i; j<M; j+=i) p[j] = false;
  }
  while(cin >> n && n) {
    int ans = 0;
    for(int i=2; i<n/2+1; ++i) {
      if(p[i]&&p[n-i]) ++ans;
    }
    cout << ans << endl;
  }
  return 0;
}