#include <iostream>
using namespace std;
#define MAX 600
int x[MAX];
void IsPrime();

int main()
{
  int input;
  int count=0;
  
  IsPrime();
  while(1){
    cin >> input;
    if(input == 0) break;
    if(input % 2 != 0) cout << 0 << endl;
    else{
      for(int i = 0 ; i < MAX ; i++){
	for(int j = i ; j < MAX ; j++){
	  if(input == x[i] + x[j]) count++;
	}
      }
    }
    if(count != 0) cout << count << endl;
    count = 0;
  }
  return 0;
}

void IsPrime()
{
  int num, i, sim;
  
  num = 0;
  sim = 3;
  x[0] = 2;

  while(num < MAX){
    for (i = 0 ; i <= num ; i++){
      if (sim % x[i] == 0)
	break;
      if(i == num){
	num++;
	if(num >= MAX)
	  break;
	x[num] = sim;
      }
    }
    sim++;
  }
}