#include <stdio.h>
#define N 33000

int main( void ) {
  int i, j;
  int num[ N ];

  for( i = 2; i < N; i++ )
    num[ i ] = 1;
  for( i = 2; i < N; i++ )
    for( j = i*2; j < N; j += i )
      num[ j ] = 0;

  while( 1 ) {
    int n;
    int count = 0;

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

    for( i = 2; i <= n/2; i++ )
        if( num[ i ] && num[ ( n-i ) ] )
          count++;

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

  return( 0 );
}