#include<stdio.h>

int sosuhantei(int a)
{
	int b=2,check=0;
	if(a==2)
		check=2;
	while(b<a)
	{
		if(check==2)
		{	
			check=0;
			break;
		}
		else 
		{
			if(a%b==0)
			{
				check=1;
				break;
			}
			b++;
		}
	}
	return check;

}

int main()
{	
	int seisu[100000],a,b,count,i=0,j,k;
	for(k=0;k<100000;k++)
	{
		seisu[k]=0;
	}
	while(1)
	{
		count=0;	
		scanf("%d",&a);
		if(a%2==1)
			seisu[i]=0;
		else if(a==0)
		{
			i++;
			break;
		}
		else 
		{
			for(j=2;j<a/2;j++)
			{
				if(sosuhantei(j)==0)
				{
					b=a-j;
					if(sosuhantei(b)==0)
						count++;
				}
			}
			seisu[i]=count;
			printf("%d",count);
		}
		i++;
	}
	for(k=0;k<i-1;k++)
	{
		printf("%d\n",seisu[k]);
	}
}