#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>
#include<math.h>


using namespace std;

bool f[10000002];
int N=1000000;
int main () {
  for(int i=3;i<=N;i+=2){f[i]=true;
	  for(int j=3;j*j<=i;j+=2)
		  if(i%j==0)f[i]=false;
  }
  int x;
  while(1){

  int ans=0;
  cin>>x;if(x==0)break;
  for(int i=3;i<=x/2;i+=2)
	  if(f[x-i]==true&&f[i]==true)ans++;//cout<<i<<" "<<x-i<<endl;//
	  
  cout<<ans<<endl;
}
  return 0;
}