#include <iostream>
#include <vector>
using namespace std;

int main() {

  vector<int> list;

  bool sosu[50000] = {false};
  for ( long long int i = 2; i < 50000; i++ ) {
    if ( sosu[i] == false ) {
      list.push_back(i);
      for ( long long int j = i*2; j < 50000; j+=i ) {
	sosu[j] = true;
      }
    }
  }

  cout << list.size() << endl;

  int n;

  while(true) {

    cin >> n;
    if ( n == 0 ) break;

    int cnt = 0;

    for ( int i = 0; i < list.size(); i++ ) {

      int k = n - list[i];
      if ( k < list[i] ) break;

      for ( int j = i; j < list.size(); j++ ) {

	if ( k == list[j] ) cnt++;
	if ( k < list[j] ) break;

      }

    }

    cout << cnt << endl;

  }

  return 0;

}