def overlap(a, b, min_length=3):
    """ return length of longest suffix of 'a' matching
        a prefix of 'b' that is at least 'min_length' 
        character long. If no such overlap exists, return 0. """
    assert a != '' and b != ''
    start = 0   # start all the way at the left
    for i in range(min_length, len(a)):
        start =  a.find(b[:min_length], start)  # look for b's suffix in a
        if start == -1:   ## no more occurrences to left 
            return 0
        elif b.startswith(a[start:]):  ## found occurrence; check if full prefix/suffix match
            return len(a) -start
        start += 1