KMP algorithm, AC