require 'prime'

prime =  Prime.each.take_while{ |p| p < (1<<14) }.to_a

while n = gets.to_i
  break if n == 0
  q = prime.each.take_while{ |p| p < n }
  p q.take_while{ |p| p <= n / 2 }.count{ |p| q.include?(n - p) }
end