#include<iostream>
#include<cmath>
#include<vector>
#define N 50000

using namespace std;

int main(){
  int i, j, k, l, n, isFound, count;
  vector<int> data;

  data.push_back(2);
  data.push_back(3);
  for(i=5; i<=N; i+=2){
    for(j=1, isFound=0; data[j]<=sqrt(i); ++j){
      if(i%data[j] == 0){
	isFound = 1;
	break;
      }
    }
    if(isFound == 0) data.push_back(i);
  }

  while(1){
    cin >> n;
    if(n == 0) break;

    for(k=0; k<data.size(); ++k){
      if(n <= data[k]) break;
    }
    l = k-1;

    for(i=0, count=0; i<k/2+1; ++i){
      for(j=l; n<=data[i]+data[j]; --j){
	if(n == data[i]+data[j]) ++count;
      }
      l = j+1;
    }

    cout << count << endl;
  }

  return 0;
}