class Dice
  def initialize(i1, i2, i3, i4, i5, i6)
    @nums = [i1, i2, i3, i4, i5, i6]
  end
  def get_top
    @nums[0]
  end
  def move_n
    move(1, 5, 2, 3, 0, 4)
  end
  def move_s
    move(4, 0, 2, 3, 5, 1)
  end
  def move_w
    move(2, 1, 5, 0, 4, 3)
  end
  def move_e
    move(3, 1, 0, 5, 4, 2)
  end
  private
  def move(i1, i2, i3, i4, i5, i6)
    @nums[0], @nums[1], @nums[2], @nums[3], @nums[4], @nums[5] =
      @nums[i1], @nums[i2], @nums[i3], @nums[i4], @nums[i5], @nums[i6]
  end
end

nums = STDIN.gets.chomp.split(' ').map(&:to_i)
dice = Dice.new(*nums)

commands = STDIN.gets.chomp.split('')
commands.each do |c|
  case c
  when 'N' then dice.move_n
  when 'S' then dice.move_s
  when 'W' then dice.move_w
  when 'E' then dice.move_e
  end
end

puts dice.get_top