#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <queue>

using namespace std;

int main(){
    int i_max = 50000;
    queue<int> prime_temp;
    queue<int> prime;
    for(int i=2; i<=i_max; i++){
        prime_temp.push(i);
    }
    while(prime_temp.empty()!=true){
        prime.push(prime_temp.front());
        //cout<<prime_temp.front()<<" "<<endl;
        int temp_top = prime_temp.front();
        int temp_size = prime_temp.size();
        for(int i=0; i<temp_size; i++){
            if(prime_temp.front()%temp_top==0){
                prime_temp.pop();
            }else{
                prime_temp.push(prime_temp.front());
                prime_temp.pop();
            }
        }
    }

    
    int x;
    while(cin>>x){
        if(x==0)break;
        int a[x];
        int b[x];
        queue<int> prime_use;
        prime_use=prime;
        int pos=0;
        while(prime_use.front()<x){
            a[pos]=prime_use.front();
            b[pos]=prime_use.front();
            prime_use.pop();
            pos++;
        }
        int count=0;
        for(int i=0; i<pos; i++){
            for(int j=i; j<pos; j++){
                if(a[i]+b[j]==x)count++;
            }
        }
        cout<<count<<endl;
    }
}