class Dice
  def initialize(men)
    @t, @s, @e, @w, @n, @b = men
  end

  def top
    @t
  end

  def move(d)
    case d
    when 'N'
      @t, @s, @b, @n = @s, @b, @n, @t
    when 'W'
      @w, @b, @e, @t = @t, @w, @b, @e
    when 'E'
      @w, @b, @e, @t = @b, @e, @t, @w
    when 'S'
      @t, @s, @b, @n = @n, @t, @s, @b
    end
  end
end

d = Dice.new(gets.split)
gets.chomp.split('').each {|dir| d.move(dir) }
puts d.top

