class Dice
   #?????????
    def initialize()
        @dice_number = [1,6,5,3,2,4]
    end
    #??????
    def swap(number)
        number.map{|n|
            @dice_number[0] ], @dice_number[n] = @dice_number[n], @dice_number[0]
        }
    end
    #?????¢
    def top
        @dice_number[0]
    end
    #??????
    def throw(command)
        #????????????????????´??¢?????????
        swap_number =[]
        case command
        when "N"
        swap_number = [2,1,4]
        swap(swap_number)
        when 'E'
            swap_number = [3, 1, 5]
            swap(swap_number)
        when 'S'
            swap_number = [4, 1, 2]
            swap(swap_number)
        when 'W'
            swap_number = [5, 1, 3]
            swap(swap_number)
        end
    end

end
number = gets.split.map(&:to_i)
command = gets.chomp.split("")

dice = Dice.new
command.map{|c|
   dice.throw(c)
}
puts number[dice.top-1]