module Main where

import Data.Functor

type Dice = (Int,Int,Int,Int,Int,Int)

top :: Dice -> Int
top (t,_,_,_,_,_) = t

type Roll = Char

roll :: Dice -> Roll -> Dice
roll (t,s,e,w,n,b) 'E'
   = (w,s,t,b,n,e)
roll (t,s,e,w,n,b) 'N'
   = (s,b,e,w,t,n)
roll (t,s,e,w,n,b) 'W'
   = (e,s,b,t,n,w)
roll (t,s,e,w,n,b) 'S'
   = (n,t,e,w,b,s)

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO ()
main = do
  { [t,s,e,w,n,b] <- getInts
  ; rolls         <- getLine
  ; print $ top $ foldl roll (t,s,e,w,n,b) rolls
  }