#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  vector<bool> prime(50100, true);
  prime[0] = prime[1] = false;
  for(int i = 2; i * i < 50100; ++i) {
    if(prime[i]) {
      for(int j = i * i; j < 50100; j += i) {
        prime[j] = false;
      }
    }
  }

  vector<int> vec;
  for(int i = 2; i <= 50000; ++i) {
    if(prime[i]) vec.push_back(i);
  }

  int n;
  while(cin >> n, n != 0) {
    int ans = 0;
    for(int i = 0; vec[i] <= n / 2; ++i) {
      if(prime[n - vec[i]]) ans++;
    }
    cout << ans << endl;
  }
}
