#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FOREACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)

static const int N = 32769;
bool prime[N];

int main()
{
  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  FOR(i, 2, N) {
    if (prime[i]) {
      for (int j = i+i; j < N; j += i) {
        prime[j] = false;
      }
    }
  }

  int n;
  while (scanf("%d", &n), n) {
    int count = 0;
    FOREQ(i, 2, n/2) {
      if (prime[i] && prime[n-i]) {
        ++count;
      }
    }
    printf("%d\n", count);
  }
}