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

int main()
{
  const int MAX_P = 50000;
  bool p[MAX_P];
  for (int i = 0; i < MAX_P; ++i)
    p[i] = true;
  p[0] = p[1] = false;

  for (int i = 2; i*i <= MAX_P; ++i) {
    if (p[i]) {
      for (int j = i+i; j < MAX_P; j += i)
	p[j] = false;
    }
  }

  vector<int> prime;
  for (int i = 0; i < MAX_P; ++i) {
    if (p[i])
      prime.push_back(i);
  }

  int n;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;

    int ans = 0;
    for (unsigned int i = 0; i < prime.size(); ++i) {
      for (unsigned int j = i; j < prime.size(); ++j) {
	if (n == prime[i]+prime[j])
	  ++ans;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}