import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;

immutable limitList = 100000;



void main() {
    int input;
    bool[] listNumbers = new bool[](limitList);
    int[] listPrimeNumbers; //List of prime numbers.

    listNumbers.fill(true);
    listNumbers[0..1] = false;
    foreach (i; 2..limitList.to!double.sqrt.to!int) {
        if (listNumbers[i]) {
            for (int j = i*2; j < limitList; j += i) listNumbers[j] = false;
        }
    }

    while ((input = readln.chomp.to!int) != 0) {
        uint count = 0;

        foreach (i; 2..(input/2)+1) {
            if(listNumbers[i] && listNumbers[input-i]) count++;
        }

        writeln(count);
    }
}