import std.stdio;
import std.string, std.conv;
import std.algorithm, std.array;
import std.typecons;

void main() {
  const int P_MAX = 500000;
  int[] primes;
  bool[] isp = new bool[P_MAX + 1];
  isp[] = true;
  isp[0] = isp[1] = false;
  for(int i = 2; i <= P_MAX; i++) {
    if(isp[i]) {
      primes ~= i;
      for(int j = 2 * i; j <= P_MAX; j += i)
        isp[j] = false;
    }
  }

  for(int N; N = readln.chomp.to!int, N; ) {
    int s = 0;
    foreach(i; primes) {
      if(i > N) break;
      foreach(j; primes) {
        if(j > i) break;
        if(i + j == N) s++;
      }
    }
    writeln(s);
  }
}