class Dice
  def initialize(ary)
    @ary = ary
  end

  def roll(direction)
    case direction
    when "E"
      tmp = @ary[0]
      @ary[0] = @ary[3]
      @ary[3] = @ary[5]
      @ary[5] = @ary[2]
      @ary[2] = tmp
    when "N"
      tmp = @ary[0]
      @ary[0] = @ary[1]
      @ary[1] = @ary[5]
      @ary[5] = @ary[4]
      @ary[4] = tmp
    when "S"
      tmp = @ary[0]
      @ary[0] = @ary[4]
      @ary[4] = @ary[5]
      @ary[5] = @ary[1]
      @ary[1] = tmp
    when "W"
      tmp = @ary[0]
      @ary[0] = @ary[2]
      @ary[2] = @ary[5]
      @ary[5] = @ary[3]
      @ary[3] = tmp
    end
  end

  def top
    puts @ary[0]
  end
end

dice = Dice.new(gets.chomp.split(" ").map(&:to_i))
method = gets.chomp.split("")
method.each do |i|
  dice.roll(i)
end
dice.top