#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
#define MAX 1000000
int prime[MAX];
bool is_prime[MAX+1];

int solve(int n){
  int p = 0; 
  vector<int> vprime;
  for(int i = 0 ; i <= n ; i ++)is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for(int i = 2 ; i <= n ; i ++){
    if(is_prime[i]){
      vprime.push_back(i);
      for(int j = i + i ; j <= n ; j += i){
	is_prime[j] = false;
      }
    }
  }
  bool ok = false;
  int cnt = 0;
  for(int i = 0 ; vprime[i] <= n/2 ; i ++){
    //cout<<vprime[i]<<" ";
    for(int j = i ; vprime[j] <= n ; j ++){
      if(vprime[i] + vprime[j] > n)break;
      if(vprime[i] + vprime[j] == n)cnt++;;
      //cout<<vprime[j]<<" ";
    }
   
    
  }
  return cnt;
}
int main(void){ 
  
  long long int n;
  
  while(cin>>n,n){
    if(n%2)cout<<"0"<<endl;
    else cout<<solve(n)<<endl;
  }
  
}