# Goldbach's Conjecture

MAX_N = 50000

# エラトステネスの篩
prime = Array.new(MAX_N + 1, true)

prime[0] = prime[1] = false
max = Math.sqrt(MAX_N).to_i

(2..max).each do |k|
  next unless prime[k]

  l = 2 * k
  while l <= MAX_N
    prime[l] = false
    l += k
  end
end

primes = []
prime.each_with_index do |f, k|
  primes << k if f
end

while line = gets
  n = line.to_i
  break if n.zero?

  n_combinations = 0
  primes.select {|k| k < n}.each do |p1|
    primes.select {|k| k <= p1}.each do |p2|
      break if p1 + p2 > n
      puts "#{p1},#{p2}"
      n_combinations += 1 if p1 + p2 == n
    end
  end

  puts n_combinations
end