s = gets.not_nil! result = String.build do |str| s.each_char do |char| if char.uppercase? str << char.downcase else str << char.upcase end end end puts result