case class Dice(top: Int, s: Int, e: Int, w: Int, n: Int, bottom: Int) {
  def rollToE = Dice(w, s, top, bottom, n, e)
  def rollToN = Dice(s, bottom, e, w, top, n)
  def rollToS = Dice(n, top, e, w, bottom, s)
  def rollToW = Dice(e, s, bottom, top, n, w)
}


object Main extends App {

  val sc = new java.util.Scanner(Console.in)

  def next() = sc.next()
  def nextInt() = next().toInt

  val start = Dice(nextInt(), nextInt(), nextInt(), nextInt(), nextInt(), nextInt())

  val commands = next()

  val end = commands.foldLeft(start) {
    case (dice, 'E') => dice.rollToE
    case (dice, 'N') => dice.rollToN
    case (dice, 'S') => dice.rollToS
    case (dice, 'W') => dice.rollToW
  }

  println(end.top)
}

