class Dice
    @up = ''
    def initialize(n)
        @up = n[0]
        @front = n[1]
        @right = n[2]
        @left = n[3]
        @back = n[4]
        @down = n[5]
    end

    def move(direction)
        case direction
        when 'S'
            tmp = @up
            @up = @back
            @back = @down
            @down = @front
            @front = tmp
        when 'W'
            tmp = @up
            @up = @right
            @right = @down
            @down = @left
            @left = tmp
        when 'E'
            tmp = @up
            @up = @left
            @left = @down
            @down = @right
            @right = tmp
        when 'N'
            tmp = @up
            @up = @front
            @front = @down
            @down = @back
            @back = tmp
        end
    end
    def displayUp
        puts @up
    end
end

x = gets.split.map(&:to_i)
directions = gets.chomp
dice = Dice.new(x)
directions.split('').each{|d| dice.move(d)}
dice.displayUp
