#include <cstdio>
#include <cmath>
using namespace std;
/*bool prime(int num) 
{
    if (num==1) return false;
    if (num==2) return true;
    if (num%2==0) return false;
    for (int i=3; i<=sqrt(num); i+=2) {
        if (num%i==0) return false;
    }
    return true;
    }*/
int powMod(int x, int k, int m) {
  if (k == 0)     return 1;
  if (k % 2 == 0) return powMod(x*x % m, k/2, m);
  else            return x*powMod(x, k-1, m) % m;
}
bool suspect(int a, int s, int d, int n) {
  int x = powMod(a, d, n);
  if (x == 1) return true;
  for (int r = 0; r < s; ++r) {
    if (x == n - 1) return true;
    x = x * x % n;
  }
  return false;
}
// {2,7,61,-1}                 is for n < 4759123141 (= 2^32)
// {2,3,5,7,11,13,17,19,23,-1} is for n < 10^16 (at least)
bool isPrime(int n) {
  if (n <= 1 || (n > 2 && n % 2 == 0)) return false;
  int test[] = {2,3,5,7,11,13,17,19,23,-1};
  int d = n - 1, s = 0;
  while (d % 2 == 0) ++s, d /= 2;
  for (int i = 0; test[i] < n && test[i] != -1; ++i)
    if (!suspect(test[i], s, d, n)) return false;
  return true;
}
int main() 
{
    int n;
    while (scanf("%d",&n)&&n!=0) {
        int res=0;
        if (n%2!=0) {
            printf("0\n");
            continue;
        }
        for (int i=1; i<=n/2; i++) {
            if (n-i<i) break;
            if (isPrime(i)&&isPrime(n-i)) {
                res++;
            }
        }
        printf("%d\n",res);
    }
}