import scala.math._

object Dice {
  type Dice[A] = (A, A, A, A, A, A)

  implicit class Tuple6Dice[A](self: Dice[A]) {

    def N: Dice[A] = self match {
      case (_1, _2, _3, _4, _5, _6) =>
        (_2, _6, _3, _4, _1, _5)
    }

    def E: Dice[A] = self match {
      case (_1, _2, _3, _4, _5, _6) =>
        (_4, _2, _1, _6, _5, _3)
    }

    def S: Dice[A] = self match {
      case (_1, _2, _3, _4, _5, _6) =>
        (_5, _1, _3, _4, _6, _2)
    }

    def W: Dice[A] = self match {
      case (_1, _2, _3, _4, _5, _6) =>
        (_3, _2, _6, _1, _5, _4)
    }

    def toList: List[A] = self match {
      case (_1, _2, _3, _4, _5, _6) =>
        List(_1, _2, _3, _4, _5, _6)
    }

    def run(commands: List[Char]): Dice[A] =
      commands.foldLeft(self) { (d, c) =>
        c match {
          case 'N' => d.N
          case 'E' => d.E
          case 'S' => d.S
          case 'W' => d.W
          case _   => d
        }
      }
  }
}

object Main extends App {
  val scanner = new java.util.Scanner(System.in)

  val label   = scanner.nextLine().split(" ")
  val command = scanner.nextLine()

  import Dice._

  val init = (1, 2, 3, 4, 5, 6)
  val fin  = init.run(command.toList)

  println(label(fin.toList.head-1))
}