int firstMatch(String s, int fromIndex, String p) {
        for (int i = fromIndex; i < s.length() - p.length() + 1; i++) {
            if (headMatch(s, i, p))
                return i;
        }
        return -1;
    }