import scala.io.StdIn.readLine

case class Dice(val d:Array[Int]) {

  private def rollOnce(dir:Char)  =
    dir match {
      case 'S' => Array(4,0,2,3,5,1)
      case 'N' => Array(1,5,2,3,0,4)
      case 'W' => Array(2,1,5,0,4,3)
      case 'E' => Array(3,1,0,5,4,2)
    }

  def roll(dirs:String)  =
    (0 until d.length).foreach { x =>
      val d2 = dirs.foldLeft(Array(0,1,2,3,4,5)) { (x,y) => rollOnce(y).map(x) }.map(d)
      d(x) = d2(x)
    }

  def getTopFace() = d(0)
}

object Main extends App {
  val faces = readLine.split(" ").map(_.toInt)
  val dice = Dice(faces)
  dice.roll(readLine)

  println(dice.getTopFace())
}