class Dice

  def initialize(surfaces)
    @surfaces = surfaces.dup 
  end

  def top
    @surfaces[0]
  end

  def N
    old = @surfaces.dup
    @surfaces[4] = old[0]
    @surfaces[5] = old[1]
    @surfaces[1] = old[5]
    @surfaces[0] = old[1]
    self
  end

  def E
    old = @surfaces.dup
    @surfaces[2] = old[0]
    @surfaces[5] = old[2]
    @surfaces[3] = old[5]
    @surfaces[0] = old[3]
    self
  end

  def S
    old = @surfaces.dup
    @surfaces[1] = old[0]
    @surfaces[5] = old[1]
    @surfaces[4] = old[5]
    @surfaces[0] = old[4]
    self
  end

  def W
    old = @surfaces.dup
    @surfaces[3] = old[0]
    @surfaces[5] = old[3]
    @surfaces[2] = old[5]
    @surfaces[0] = old[2]
    self
  end
end

n = gets.chomp.split.map(&:to_i)
c = gets.chomp

d = Dice.new(n)
c.each_char{|m| d.send(m) }
puts d.top