#include <stdio.h>

#define PMX ( 1 << 15 )

static
int primes[ PMX ] = { 0 };
static
int primen = 0;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( j = 2; j < PMX; ++j )
  {
    if ( primes[ j ] )  continue;

    primes[ primen++ ] = j;
    for ( i = j; i < PMX; i += j )
    {
      primes[ i ] = -1;
    }
  }

  for ( ; ; )
  {
    int n;
    int res = 0;

    scanf ( "%d", &n );
    if ( n == 0 ) break ;

    for ( j = 0; j < primen && primes[ j ] < n; ++j )
    for ( i = j; i < primen; ++i )
    {
      int sum = primes[ j ] + primes[ i ];

      if ( sum >= n )
      {
        res += !!( sum == n );
        break;
      }
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}