#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
int p[1000];

int main(){
	int n,m,k,l,count;
	while ((cin >> n), n){
		count = 0;
		k = 1;
		p[0] = 2;
		p[1] = 3;
		m = n / 2 + 1;
		for (int i = 4; i < m; i++){
			for (int j = 2; i >= (j-1)*(j-1); j++){
				if (i < j*j){
					k++; p[k] = i;
				
				}
				else if (i%j == 0)break;
			}
		}
		for (int i = 0; i <= k; i++){
			l = n - p[i]; if (l == 1)break;
			for (int j = 2; (j-1)*(j-1) <= l; j++)
			{
				if (l < j*j)count++;
				else if (l%j == 0)break;

				}
		}
		cout << count << endl;
	}
        return 0;

}