#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
pair<vl,vb> eratosthenes_sieve(ll n){
  vb is_prime(n+1,true);
  vl prime;
  is_prime[0] = false;
  is_prime[1] = false; 
  FOR(i,2,n+1){
    if(!is_prime[i]) continue;
    for(ll j=2*i;j<=n;j+=i) is_prime[j] = false;
    prime.eb(i);
  }
  return {prime,is_prime};
}
signed main(){
  vl prime;
  vb is_prime;
  tie(prime,is_prime) = eratosthenes_sieve(50000);
  ll n;
  while(cin>>n,n){
    ll ans = 0;
    for(ll i=0;prime[i]<=n/2;++i){
      if(is_prime[n-prime[i]]) ++ans;
    }
    cout << ans << endl;
  }
}
