#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 50000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;
vector<int> vec;
bool prime[LIM];

void eratos(){
  rep(i,LIM)prime[i] = false;
  for(int i=3;i<LIM;i+=2)prime[i] = true;
  prime[2] = true;

  for(int i=3;i<=sqrt(LIM);i+=2){
    if(!prime[i])continue;
    for(int j=i+i;j<=sqrt(LIM);j+=i)
      prime[j] = false;
  }

  rep(i,LIM)
    if(prime[i])
      vec.pb(i);
    
}

string itos(int a,int b){
  stringstream ss;
  ss << a << "+" << b;
  return ss.str();
}

int main(){
  eratos();
  int n;
  while(true){
    cin >> n;
    if(n == 0)break;
    map<string,bool> used;
    int cnt = 0;
    for(int i=0;vec[i] <= n;i++){
      for(int j=0;vec[j] <= n;j++){
	if(vec[i]+vec[j] == n && !used[itos(vec[i],vec[j])]){
	  used[itos(vec[i],vec[j])] = used[itos(vec[j],vec[i])] = true;
	  cnt++;
	}
      }
    }
    cout << cnt << endl;
  }


return 0;
}