  class Price(value: Double, currency: String) {
    val bitCoinToYenRate = 380000

    def toYen(): Double = {
      currency match {
        case "JPY" => value
        case "BTC" => value * bitCoinToYenRate
        case _ => throw new IllegalStateException(s"invalid currency received: ${currency}")
      }
    }
  }

  import io.StdIn._
  object Main extends App {

    val otosidamaCount = readInt()
    val values = readLine().split(' ').map(_.toDouble)
    val currencies = readLine().split(' ')
    val jpyValues = values.zip(currencies).map { case (value, currency) => new Price(value, currency).toYen() }
    println(jpyValues.sum)
  }