#include <cstdio>
using namespace std;
bool prime(int num) 
{
    if (num==2) return true;
    for (int i=3; i*i<=num; i+=2) {
        if (num%i==0) return false;
    }
    return true;
}
int main() 
{
    int n;
    while (scanf("%d",&n)&&n!=0) {
        int res=0;
        if (n%2!=0) {
            printf("0\n");
            continue;
        }
        if (n==4) res++;
        for (int i=3; i<=n/2; i+=2) {
            if (prime(i)&&prime(n-i)) {
                res++;
            }
        }
        printf("%d\n",res);
    }
}