require 'prime'

until (n=gets.to_i)==0
  m = n/2
  
  cnt = 0
  while m >= 3
    if Prime.prime?(m) && Prime.prime?(n-m)
      cnt += 1
    end

    m -= 2
  end

  cnt += 1 if Prime.prime?(n-2)

  puts cnt
end