p=[2]
tmp=3
while p[p.length-1] < 25000
  flag = true
  for i in 0.. p.length-1
    if tmp % p[i] == 0
      flag = false
      break
    end
  end
  if flag
    p.push(tmp)
  end
  tmp+=1
end
while g=gets.to_i
  if g==0 then break end
  c=0
  i=0
  while p[i] < g/2+1
    if p.index(g-p[i]) then c+=1 end
    i+=1
  end
  puts c
end