#include <iostream>
#include <vector>
int main(){
  std::vector<int> v;
  v.push_back(2);
  bool f;
  for(int i=3;i<=50000;i+=2){
    f=true;
    for(int j=0;v[j]*v[j]<=i;j++){
      if(!(i%v[j])){f=false;break;}
      std::cout<<"Error"<<std::endl;
    }
    if(f)v.push_back(i);
  }
  int n,c;
  while(std::cin>>n){
    if(!n)break;
    c=0;
    for(int i=0;v[i]<=n/2;i++){
      for(int j=0;v[i]+v[j]<=n;j++){
	if(v[i]+v[j]==n)c++;
      }
    }
    std::cout<<c<<std::endl;
  }
  return 0;
}