#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
#define pb push_back
int n;
bool sieve[40000];
vector<int> primes;

void solve() {
  int res = 0;
  for (int i = 0; i < primes.size(); i += 1) {
    int t_sum = primes[i];
    for (int j = i; j < primes.size(); j += 1) {
      if (t_sum + primes[j] == n) {
        res++;
        break;
      } else if (t_sum + primes[j] > n) {
        break;
      }
    }
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  // set sieve
  memset(sieve, true, sizeof sieve);
  for (int i = 2; i < 40000; i += 1) {
    if (sieve[i]) {
      primes.pb(i);
      for (int j = i+i; j < 40000; j += i) {
        sieve[j] = false;
      }
    }
  }
  
  while (cin>>n, n) {
    solve();
  }
  return 0;
}