import scala.io.StdIn.readLine

class Dice(var d:Array[Int]) {
  val s = Array(4,0,2,3,5,1)
  val n = Array(1,5,2,3,0,4)
  val w = Array(2,1,5,0,4,3)
  val e = Array(3,1,0,5,4,2)

  def roll(dir:Char)  =
    d = dir match {
      case 'S' => s.map(d)
      case 'N' => n.map(d)
      case 'W' => w.map(d)
      case 'E' => e.map(d)
    }

  def getTopFace() = d(0)
}

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

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