dice   = gets.split.map(&:to_i)
action = gets.chomp
upper  = dice[0]
side   = [ dice[4], dice[2], dice[1], dice[3] ]
bottom = dice[5]
action.chars do |str|
  b = bottom
  u = upper
  case str
  when "N"
    upper   = side[2]
    bottom  = side[0]
    side[2] = b
    side[0] = u
  when "E"
    upper   = side[3]
    bottom  = side[1]
    side[3] = b
    side[1] = u
  when "S"
    upper   = side[0]
    bottom  = side[2]
    side[0] = b
    side[2] = u
  when "W"
    upper   = side[1]
    bottom  = side[3]
    side[1] = b
    side[3] = u
  end
end
puts upper