import java.io.InputStream
import java.io.PrintStream

import scala.io.Source

case class Dice(numbers: Seq[Int])

sealed trait Command
object N extends Command
object E extends Command
object W extends Command
object S extends Command

case class DiceState(
    top: Int = 0,
    south: Int = 1,
    east: Int = 2,
    west: Int = 3,
    north: Int = 4,
    bottom: Int = 5) {

  def runCommand(command: Command): DiceState = command match {
    case N => copy(top = south, south = bottom, bottom = north, north = top)
    case E => copy(top = west, west = bottom, bottom = east, east = top)
    case W => copy(top = east, east = bottom, bottom = west, west = top)
    case S => copy(top = north, north = bottom, bottom = south, south = top)
  }
}

object Main {

  def run(in: InputStream, out: PrintStream): Unit = {
    val (dice, commands) = input(in)
    val state = commands.foldLeft(new DiceState())((s, c) => s.runCommand(c))
    out.println(dice.numbers(state.top))
  }

  private def input(in: InputStream): Tuple2[Dice, Seq[Command]] = {
    val lines = Source.fromInputStream(in).getLines()
    val dice = toDice(nextLine(lines, "??????????????¢?????°"))
    val commands = toCommands(nextLine(lines, "??????"))
    return (dice, commands)
  }

  private def toDice(line: String): Dice = {
    val numbers = line.split(' ')
    if (numbers.length != 6) {
      throw new IllegalArgumentException(s"??????????????¢?????°????????£??§???: $line");
    }

    return new Dice(numbers.map(_.toInt))
  }

  private def toCommands(line: String): Seq[Command] = {
    return line.map(toCommand)
  }

  private def toCommand(char: Char): Command = char match {
    case 'N' => N
    case 'E' => E
    case 'W' => W
    case 'S' => S
    case _ => throw new IllegalArgumentException(s"?????????????????????????????§???: ${char}")
  }

  def nextLine(lines: Iterator[String], label: String): String = {
    if (!lines.hasNext) {
      throw new IllegalArgumentException(s"${label}??????????????\????????????????????????")
    }
    return lines.next()
  }

  def main(args: Array[String]): Unit = {
    try {
      run(System.in, System.out)
    } catch {
      case e: Exception => {
        System.err.println(s"??¨??????: ${e.getMessage()}")
        e.printStackTrace()
      }
    }
  }
}