object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val diceNum = sc.nextLine().split(" ")
  val cmds = sc.nextLine().toList.map(_.toString)

  val dice = new Dice(diceNum)
  cmds.foreach(dice.roll)

  println(dice.getCurrentPositionMap.get(Position.TOP).get)

  class Dice(val num: Array[String]) {
    val initNumber = num.map(_.toInt)
    private val controller = createPositionController

    def roll(cmd: String): Unit = {
      controller(cmd)
    }

    def getCurrentPositionMap = controller("0")

    def createPositionController: (String) => scala.collection.mutable.Map[String, Int] = {
      val current = scala.collection.mutable.Map(
        Position.TOP -> initNumber(DiceLabel._1),
        Position.BOTTOM -> initNumber(DiceLabel._6),
        Position.EAST -> initNumber(DiceLabel._3),
        Position.WEST -> initNumber(DiceLabel._4),
        Position.SOUTH -> initNumber(DiceLabel._2),
        Position.NORTH -> initNumber(DiceLabel._5)
      )
      (cmd: String) => {
        cmd match {
          case "E" =>
            val tmp = current.get(Position.EAST).get
            current.update(Position.EAST, current.get(Position.TOP).get)
            current.update(Position.TOP, current.get(Position.WEST).get)
            current.update(Position.WEST, current.get(Position.BOTTOM).get)
            current.update(Position.BOTTOM, tmp)
            current
          case "W" =>
            val tmp = current.get(Position.WEST).get
            current.update(Position.WEST, current.get(Position.TOP).get)
            current.update(Position.TOP, current.get(Position.EAST).get)
            current.update(Position.EAST, current.get(Position.BOTTOM).get)
            current.update(Position.BOTTOM, tmp)
            current
          case "S" =>
            val tmp = current.get(Position.SOUTH).get
            current.update(Position.SOUTH, current.get(Position.TOP).get)
            current.update(Position.TOP, current.get(Position.NORTH).get)
            current.update(Position.NORTH, current.get(Position.BOTTOM).get)
            current.update(Position.BOTTOM, tmp)
            current
          case "N" =>
            val tmp = current.get(Position.NORTH).get
            current.update(Position.NORTH, current.get(Position.TOP).get)
            current.update(Position.TOP, current.get(Position.SOUTH).get)
            current.update(Position.SOUTH, current.get(Position.BOTTOM).get)
            current.update(Position.BOTTOM, tmp)
            current
          case "0" => current
        }
      }
    }

    object DiceLabel extends Enumeration {
      val _1 = 0
      val _2 = 1
      val _3 = 2
      val _4 = 3
      val _5 = 4
      val _6 = 5
    }

  }

  object Position extends Enumeration {
    val TOP = "TOP"
    val BOTTOM = "BOTTOM"
    val EAST = "EAST"
    val WEST = "WEST"
    val SOUTH = "SOUTH"
    val NORTH = "NORTH"
  }

}