fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val otoshidamas = Array(n) {
        readLine()!!.split(" ").let {
            when (it[1]) {
                "JPY" -> Money.JPY(it[0].toInt())
                "BTC" -> Money.BTC(it[0].toDouble())
                else -> error("unknown money type")
            }
        }
    }
    println(otoshidamas.sumByDouble {
        it.toJPY()
    })
}

sealed class Money {
    class JPY(val yen: Int) : Money()
    class BTC(val btc: Double) : Money()

    fun toJPY(): Double = when (this) {
        is JPY -> yen.toDouble()
        is BTC -> btc * 380000
    }
}
