import scala.io.StdIn.readLine

class Dice(var d:List[Int]) {
  val fs = (x:List[Int]) => x match {case List(x1,x2,x3,x4,x5,x6) => List(x5,x1,x3,x4,x6,x2) }
  val fn = (x:List[Int]) => x match {case List(x5,x1,x3,x4,x6,x2) => List(x1,x2,x3,x4,x5,x6) }
  val fw = (x:List[Int]) => x match {case List(x1,x2,x3,x4,x5,x6) => List(x3,x2,x6,x1,x5,x4) }
  val fe = (x:List[Int]) => x match {case List(x3,x2,x6,x1,x5,x4) => List(x1,x2,x3,x4,x5,x6) }

  def roll(dir:Char)  =
    d = dir match {
      case 'S' => fs(d)
      case 'N' => fn(d)
      case 'W' => fw(d)
      case 'E' => fe(d)
    }

  def getTopFace() = d(0)
}

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

  readLine.foreach { dice.roll _ }
  println(dice.getTopFace)
}