#include <cstdio>

const int maxn = (1<<15)+1;

int primes[maxn], cnt = 0;
bool not_prime[maxn];

void find_all_primes() {
    for(int i=2;i<maxn;i++)
        if(!not_prime[i]) {
            primes[cnt++] = i;
            for(int j=i+i;j<maxn;j+=i) not_prime[j] = true;
        }
}

int summary[maxn];

void get_all_summary() {
    for(int i=0;i<cnt;i++)
        for(int j=i;j<cnt;j++) {
            int tmp = primes[i] + primes[j];
            if(tmp >= maxn) break;
            summary[tmp] ++;
        }
}

int a;

int main() {
    find_all_primes();
    get_all_summary();
    while(~scanf("%d", &a) && a) {
        printf("%d\n", summary[a]);
    }
    return 0;
}