not_prime = Array.new(5133, false)

not_prime[0] = true
not_prime[1] = true

not_prime.each_with_index {|elem, i|

    if i <= 1 or i > Math.sqrt(5133) then
      next
    end

    if not_prime[i] == false   
      j = 2 * i
      while j <= 104730
        not_prime[j] = true
        j += i
      end
    end
}

not_prime.each_with_index {|elem, i|

  if i <= 100 and not_prime[i] == true then
    puts i
  end

}

# puts "Input a string"

while (n = gets_to_i) > 0

  ans = 0

  index = 2 

  (n/2-1).times {

    if not_prime[index] == false and not_prime[n-index] == false then
      ans += 1
    end

    index += 1
  }

  puts ans

end