#include<stdio.h>

#define MAX 100000
#define sqrtMAX 317

int main(void)
{
  int n;
  int *b;
  b = malloc((MAX+1)*sizeof(int));
  int *p;
  p = malloc((MAX+1)*sizeof(int));
  int *c;
  c = malloc((MAX+1)*sizeof(int));
/*
  int b[MAX+1] = {0};
  int p[MAX+1] = {0};
  int c[MAX+1] = {0};
*/
  int i, j;
  int count;

  // ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
  b[0] = 1;
  b[1] = 1;
  for(i=4; i<=MAX; i+=2)
      b[i] = 1;
  for(i=3; i<sqrtMAX; i+=2)
      for(j=i+i; j<=MAX; j+=i)
          b[j] = 1;

  // ツ素ツ青板づーツ板イツつォツ出ツつキ
  count = 0;
  for(i=0; i<=MAX; i++) {
    if(b[i])
      continue;
    p[count++] = i;
  }

  for(i=0; i<count; i++) {
    for(j=i; j<count; j++) {
      if(p[i]+p[j] > MAX)
        break;
      c[p[i]+p[j]]++;
    }
  }

  while(scanf("%d", &n)!=EOF) {
    if(n==0)
      break;
    printf("%d\n", c[n]);
  }

  free(b);
  free(p);
  free(c);

  return 0;
}