object Main extends App {
  import scala.io.StdIn._
  val Array(x, a, b) = readLine.trim.split(' ').map(_.toInt)
  val n = readInt()
  println(
    Array.fill(n){readLine.trim}.foldLeft(x){
      case (current, "nobiro") ⇒ math.max(0, current + a)
      case (current, "tidime") ⇒ math.max(0, current + b)
      case (_, "karero") ⇒ 0
      case _ ⇒ ???
    }
  )
}
