main = do
  xs <- (return . map (read::String->Int) . words) =<< getLine
  cs <- getLine
  print $ head $ foldl f xs cs
  
f [x1,x2,x3,x4,x5,x6] c |c == 'N' = [x2,x6,x3,x4,x1,x5]
f [x1,x2,x3,x4,x5,x6] c |c == 'S' = [x5,x1,x3,x4,x6,x2]
f [x1,x2,x3,x4,x5,x6] c |c == 'E' = [x4,x2,x1,x6,x5,x3]
f [x1,x2,x3,x4,x5,x6] c |c == 'W' = [x3,x2,x6,x1,x5,x4]
