#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  vector<i64> primes;
  vector<int> is(50505, true);
  rep(i,2,50505) {
    if(is[i]) {
      primes.push_back(i);
      for(int j = i + i; j < 50505; j += i) {
        is[j] = false;
      }
    }
  }
  i64 n;
  while((cin >> n), n != 0) {
    i64 i = 0;
    i64 j = primes.size();
    i64 cnt = 0;
    for(int i = 0;i < primes.size();i++) {
      i64 p = primes[i];
      if(p <= n - p && is[n - p]) {
        cnt++;
      }
    }
    cout << cnt << "\n";
  }
}

