#include<iostream>
#include<vector>
using namespace std;

int main()
{
  bool pri[1000001];
  vector<int> price;
  fill(pri,pri+1000001,true);
  pri[0]=pri[1]=false;
  for(int i=2;i<1000001;i++)
    {
      if(pri[i]==0)
	continue;
      price.push_back(i);	
      for(int j=i+i;j<1000001;j+=i)
	{
	  pri[j]=false;
	}
    }
  int n;
  for(;cin>>n,n;)
    {     
      int count=0;

      for(int i=0;i<price.size();i++)
	{
	  for(int j=i;j<price.size();j++)
	    {
	      if(price[i]+price[j]==n)
		count++;
	      if(price[j]>=n)
		break;
	    }
	  if(price[i]>=n)
	    break;
	}
      cout<<count<<endl;
    
    }
 
}