import scala.io.Source

object Main extends App {
  val src = Source.stdin.getLines
  val org_dice = src.next.split(" ").map(_.toInt).toList
  val directions = src.next

  def sDirection(dice: List[Int]) = List(dice(4), dice(0), dice(2), dice(3), dice(5), dice(1))
  def nDirection(dice: List[Int]) = List(dice(1), dice(5), dice(2), dice(3), dice(0), dice(4))
  def wDirection(dice: List[Int]) = List(dice(2), dice(1), dice(5), dice(0), dice(4), dice(3))
  def eDirection(dice: List[Int]) = List(dice(3), dice(1), dice(0), dice(5), dice(4), dice(2))

  def roll(dice: List[Int], direction: Char): List[Int] = {
    if (direction == 'N') nDirection(dice)
    else if (direction == 'S') sDirection(dice)
    else if (direction == 'E') eDirection(dice)
    else wDirection(dice)
  }

  println(directions.foldLeft(org_dice)(roll).head)
}