#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define M 32769

int main(void){

  int i,j;
  int n;
  char *a;
  int count;

  a = (char *)malloc(sizeof(char)*M);

  for(i=2;i<M;i++)a[i] = 1;
  a[0]=0;
  a[1]=0;

  i=2;
  while(i<M){
    for(j=2*i;j<M;j+=i)a[j] = 0;
    while(!a[++i]);
  }

  while(1){
    scanf("%d",&n);
    if(n==0)break;
    count = 0;

    for(i=1;i<=n/2;i++)if(a[i] && a[n-i])count++;

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

  return 0;
}