#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    bool prime[200000];
    int primeNum[10100] = {0};
    rep(i,105000){
        prime[i] = true;
    }
    prime[0] = false;
    prime[1] = false;
    int j = 1;
    rep(i,105000){
        if(prime[i]){
            primeNum[j] = i;
            j++;
            for(int k = 2 * i; k < 105000; k+= i){
                prime[k] = false;
            }
        }
    }
    int input;
    while(cin >> input, input){
        int ans = 0;
        range(i,1,105000){
            if(input < primeNum[i]) break;
            range(k,i,105000){
                if(input == primeNum[i] + primeNum[k]) ans++;
                if(input < primeNum[i] + primeNum[k]) break;
            }
        }
        cout << ans << endl;
    }
}