//50000 for aizu0056
//1000000 for aizu0185
#define M 32769
p[M+1];


int main(){
  int n,i=2,j;
  p[1]=1;
  for(;i<=M;i++)
    if(!p[i])
      for(j=i*2;j<=M;j+=i)
        p[j]=1;
  for(;scanf("%d",&n),n;){
    int i=2,s=0;
    for(;i<=n/2;i++){
      if(p[i])continue;
      if(!p[n-i]){
        s++;
      }
    }
    printf("%d\n",s);
  }
  return 0;
}