#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)

int n;

// Millar-Rabin

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;
}

bool is_prime(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(){
    while(cin>>n && n) {
        int ans = 0;
        if(n % 2 == 1) { cout<<0<<endl; continue; }
        for(int a=1; a<=n/2; a++) {
            int b = n-a;
            if(is_prime(a) && is_prime(b)) ++ans;
        }
        cout << ans << "\n";
    }


    return 0;
}