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



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

    listNumbers.fill(true);
    foreach (i; 2..50000) {
        if (listNumbers[i]) {
            for (int j = i*2; j < 50000; j += i) listNumbers[j] = false;
        }
    }

    foreach (i; 2..listNumbers.length) {
        if (listNumbers[i]) {
            listPrimeNumbers ~= i.to!int;
        }
    }

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

        foreach (i; 0..listPrimeNumbers.length) {
            foreach (j; i..listPrimeNumbers.length) {
                if ((listPrimeNumbers[i] + listPrimeNumbers[j]) == input) count++;
            }
        }

        writeln(count);
    }
}