#include <iostream>

using namespace std;


int isPrime(int in) {
  int flag = 1;
  if(in == 1) return 0;
  for(int i = 2;i * i <= in;i++){
    if(in % i == 0) flag = 0;
  }
  return flag;
}


int main(){

  int n,a,ans = 0;

  while(true){

  cin >> n;
  if(n == 0) break;
  for(int i = 2;i <=  n / 2;i++){
    if(isPrime(i) == 1) {
      a = n - i;
      if(isPrime(a) == 1){
	ans++;
	//	cout << a <<  ' ' << i << endl;
      }
    }
  }
  cout << ans << endl;
  ans = 0;
  }
}