/* ACM ICPC Asia 98 Tokyo Problem A: Golbach's Conjecture by Naoyuki Tamura (tamura@kobe-u.ac.jp) */ import java.io.*; import java.util.*; public class A { static boolean dbg = false; static DataInputStream in = new DataInputStream(System.in); static int N; static int primes[]; static void debug(String msg) { if (dbg) System.err.print(msg); } static void initPrimes() throws Exception { Vector p = new Vector(); for (int i = 2; i < 0x10000; i++) { if (isPrime(i)) { p.addElement(new Integer(i)); } } int n = p.size(); primes = new int[n]; for (int i = 0; i < n; i++) primes[i] = ((Integer)(p.elementAt(i))).intValue(); debug("# " + n + " primes\n"); } static boolean isPrime(int p) { if (p % 2 == 0) return p == 2; for (int i = 3; i*i <= p; i += 2) { if (p % i == 0) return false; } return true; } static boolean read() throws Exception { String line = null; debug("# Enter\n"); line = in.readLine(); N = Integer.parseInt(line); if (N == 0) return false; return true; } static int solve(int n) { int c = 0; for (int i = 0; i < primes.length; i++) { if (primes[i]+primes[i] > n) break; for (int j = i; j < primes.length; j++) { int p = primes[i] + primes[j]; if (p > n) break; if (p == n) { debug("# " + n + " = "); debug(primes[i] + " + " + primes[j] + "\n"); c++; } } } return c; } public static void main(String args[]) { if (args.length > 0) dbg = true; try { initPrimes(); while (read()) { int c = solve(N); System.out.println(c); } } catch (Exception e) { e.printStackTrace(); } } }