import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    auto ns = stdin.byLine().map!(to!int).array().until(0).array();
    immutable m = reduce!max(ns)+1;
    auto p = new bool[m];
    foreach(i;2..m) if(!p[i]) for(int j=2; i*j<m; ++j) p[i*j]=true;
    foreach(n;ns)
    {
        if(n&1)
            writeln(n<4 && p[n-2]?0:1);
        else
            writeln(iota(3,n/2+1,2).count!(i=>!p[i]&&!p[n-i]));
    }
}