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

const int MAXP = 1000001;
bool isP[MAXP];
vector<int> Ps;

int main() {
  fill(isP, isP+MAXP, true);
  isP[0] = isP[1] = false;
  for(int i = 2; i < MAXP; ++i) {
    if(!isP[i]) continue;
    Ps.push_back(i);
    for(int j = i*2; j < MAXP; j += i) isP[j] = false;
  }
  for(int n; cin >> n && n;) {
    int res = 0;
    for(int i = 0; i < Ps.size(); ++i) {
      int p = Ps[i];
      int q = n - Ps[i];
      if(p <= q && isP[q]) {
        ++res;
      }
    }
    cout << res << endl;
  }
  return 0;
}