#include <stdio.h>

int prime_judge(int x) {
  int i = 2;
  int tf = 1;
  while(i * i <= x) {
    if(x % i == 0) {
      tf = 0;
      break;
    }
  }

  return tf;
}

int main() {
  int n;

  while(1) {
    int count = 0;
    int sep;
    scanf("%d\n", &n);
    if(n == 4) {
      printf("1\n");
    } else if(n == 0) {
      break;
    } else {
      for(sep = 3;sep <= n / 2;sep = sep + 2) {
	if(prime_judge(sep) == 1 && prime_judge(n - sep) == 1) {
	  count++;
	}
      }

      printf("%d\n", count);
    }
  }

  return 0;
}