#include <iostream>
#include <algorithm>
#include <vector>
#define N_MAX (1<<15)
using namespace std;

bool isPrime[N_MAX];
vector<int> prime;


void make() {
  fill(isPrime, isPrime+N_MAX, true);
  isPrime[0] = isPrime[1] = false;
  for(int i = 2; i < N_MAX; ++i) {
    if(isPrime[i]) {
      prime.push_back(i);
      for(int j = i*2; j < N_MAX; j += i) isPrime[j] = false;
    }
  }
}


void solve(int &n) {
  int ans = 0;
  for(int i = 0; i < prime.size() &&  prime[i] <= n/2; ++i) {
    if(isPrime[n-prime[i]]) ans++;
  }
  cout << ans << endl;
}

int main() {
  int n;
  make();
  while((cin >> n) && n) solve(n);
}