#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
using namespace std;
#define MAX 1000000
bool prime[MAX];
int main(void){ 

  fill(prime,prime+MAX,true);
  prime[0] = prime[1] = false;
  for(int i = 2 ; MAX > i * i ; i ++){
    if(prime[i]){
      for(int j = i + i ; MAX > j * j ; j += i){
	prime[j] = false;
      }
    }
  } 
  int n;
  while(cin>>n,n){
    if(n%2)cout<<"0"<<endl;
    else{
      int cnt = 0,sum = 0;
      for(int i = 0 ; i <= n/2 ; i ++){
	for(int j = n/2 ; j < n ; j ++){
	  if(prime[i] && prime[j]){
	    if(i+j==n)cnt++;
	  } 
	}
      } 
      cout<<cnt<<endl;
    }
  }
}