lst = []
gets.to_i.times do |i|
    lst.push(gets.split(" "))
end

btc = lst.select{|i| i[1] == "BTC"}.map{|i|i[0].to_f}.reduce(:+)
p btc

btctojpy = btc * 380000.00.to_f

jpy = lst.select{|i| i[1] = "JPY"}.map{|i|i[0].to_f}.reduce(:+)

puts jpy.to_f + btctojpy
 