class Dice
    @numbers = []

    def initialize numbers
        @numbers = numbers
    end

    def roll direction
        old = @numbers.dup
        case direction
        when "N"
            @numbers[0] = old[1]
            @numbers[1] = old[5] 
            @numbers[5] = old[4]
            @numbers[4] = old[0]
            @numbers[2] = old[2]
            @numbers[3] = old[3]
        when "E"
            @numbers[3] = old[5]
            @numbers[0] = old[3] 
            @numbers[2] = old[0]
            @numbers[5] = old[2]
            @numbers[1] = old[1]
            @numbers[4] = old[4]
        when "S"
            @numbers[0] = old[4]
            @numbers[1] = old[0] 
            @numbers[5] = old[1]
            @numbers[4] = old[5]
            @numbers[2] = old[2]
            @numbers[3] = old[3]
        when "W"
            @numbers[3] = old[0]
            @numbers[0] = old[2] 
            @numbers[2] = old[5]
            @numbers[5] = old[3]
            @numbers[1] = old[1]
            @numbers[4] = old[4]
        end
    end

    def top
        @numbers[0]
    end
end

numbers = gets.chomp.split.map(&:to_i)
dice = Dice.new(numbers)
directions = gets.chomp.split("")
directions.each{|direction| dice.roll direction}
puts dice.top