import scala.io.StdIn
/**
  * AOJ
  */

sealed trait Side

object Up extends Side
object North extends Side
object East extends Side
object West extends Side
object South extends Side
object Under extends Side

object Main {

  def main(args: Array[String]): Unit = {

    val diceMap = List(Up,North,East,West,South,Under).zip(StdIn.readLine().split(" ").map(_.toInt)).toMap
    val cmdList = StdIn.readLine().toCharArray
    println(cmdList.foldLeft(diceMap){(x,y) => getNextStatus(y,x)}(Up))
  }

  def getNextStatus(cmd:Char,dice:Map[Side,Int]): Map[Side,Int] = {
    cmd match {
      case 'E' => Map(Up -> dice(West),North -> dice(North),East -> dice(Up),West -> dice(Under),South -> dice(South),Under -> dice(East))
      case 'N' => Map(Up -> dice(North),North -> dice(Under),East -> dice(East),West -> dice(West),South -> dice(Up),Under -> dice(South))
      case 'S' => Map(Up -> dice(South),North -> dice(Up),East -> dice(East),West -> dice(West),South -> dice(Under),Under -> dice(North))
      case 'W' => Map(Up -> dice(East),North -> dice(North),East -> dice(Under),West -> dice(Up),South -> dice(South),Under -> dice(West))
    }
  }
}