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

    def move(dir)
        case
        when dir == "N"
            @ary = [@ary[1], @ary[5], @ary[2], @ary[3], @ary[0], @ary[4]]
        when dir == "S"
            @ary = [@ary[4], @ary[0], @ary[2], @ary[3], @ary[5], @ary[1]]
        when dir == "W"
            @ary = [@ary[2], @ary[1], @ary[5], @ary[0], @ary[4], @ary[3]]
        when dir == "E"
            @ary = [@ary[3], @ary[1], @ary[0], @ary[5], @ary[4], @ary[2]]
        end
    end

    def ret
        p @ary[0]
    end
end
array = gets.split.map(&:to_i)
directions = gets.split("").map(&:to_s)

dice = Dice.new(array)
directions.size.times do |i|
    dice.move(directions[i])
end
dice.ret
