object Main extends App {
  // N個の値     x1,x2,...xN
  // N個の文字列  u1,u2,...uN
  // Uiは 'JPY' or 'BTC'

  final private val DELIMITER = " "
  final private val BTC = BigDecimal(380000)

  var num: Int = _
  val prices = io.Source.stdin.getLines().zipWithIndex.map {
    case (line, index) if index == 0 =>
      num = line.toInt
      None
    case (line, _) =>
      val lines = line.split(DELIMITER)
      val price = BigDecimal(lines(0))
      val cur = lines(1)
      Option((price, cur))
  }

  val sumYen: BigDecimal = prices.flatten.foldLeft(BigDecimal(0)) { (acc, p) =>
    p._2 match {
      case "JPY" => acc + p._1
      case "BTC" => acc + p._1 * BTC
    }
  }
  println(sumYen)
}