
object Main extends App{

  override def main(args : Array[String]) : Unit = {
     val str = io.StdIn.readLine.split(' ')
     
     val init = new Dice(str(0),str(1),str(2),str(3),str(4),str(5))
     val ops = io.StdIn.readLine
     
     val dice = ops.foldLeft(init)((z,n)=>
       n match {
         case 'N' => z.toNorth
         case 'S' => z.toSouth
         case 'W' => z.toWest
         case 'E' => z.toEast
       }
     )
     
     println(dice.top)
  }
  
  case class Dice(top: String, south: String, east: String, west: String, north: String, buttom: String) {

    def toNorth: Dice = {
      new Dice(south, buttom, east, west, top, north)
    }
    def toSouth: Dice = {
      new Dice(north, top, east, west, buttom, south)
    }
    def toEast: Dice = {
      new Dice(west, south, top, buttom, north, east)
    }
    def toWest: Dice = {
      new Dice(east, south, buttom, top, north, west)
    }

  }

}