int (@NotNull CharSequence text, @NotNull CharSequence buffer, int start) { assert start >= 0 : start; int length = text.length(); if(buffer.length() - start < length) { return start == 0 ? Integer.MIN_VALUE : -start; } for(int i = 0; i < length; i++){ int k = i + start; if(text.charAt(i) != buffer.charAt(k)) { return k == 0 ? Integer.MIN_VALUE : -k; } } return start + length; }