#include <iostream>
using namespace std;

int f[500000],s[42000];

int main() {
   int n,i,j,k=0;
   for (i=2;i<500000;i++) if (f[i]==0) {
	   f[i]=1; s[k++]=i;
	   for (j=i+i;j<500000;j+=i) f[j]=2;
   }
   while ( cin >> n && n>0) {
	   for (i=0,j=0;s[i]<=n/2;i++) if (f[n-s[i]]==1)  j++;
	   cout << j << endl;
   }  
return 0;
}	