#include <stdio.h>
#include <math.h>

int main()
{
	int x, n, b;

	while(1){
		scanf("%d", &n);
		if(n == 0) return 0;

		b = 0;

		if(n%2 != 0){
			for (int i = 2; i < sqrt(n-2)+1; i++) {
				if((n-2)%i == 0) {x = 1; break;}
			}

			if(x == 0) b++;
		}else{
			for (int i = 2; i < n/2; i++){
				x = 0;
				i++;

				for (int j = 2; j < sqrt(i)+1; j++){
					if(i%j == 0) {x = 1; break;}
				}

				if(x == 0){
					for (int j = 2; j < sqrt(n-i)+1; j++){
						if((n-i)%j == 0) {x = 1; break;}
					}

					if(x == 0) b++;
				}
			}
		}

		printf("%d\n", b);
	}

	return 0;
}