def runlength(blk, p0, p1):
    """ p0 is the source position, p1 is the dest position
    Return the length of run of common chars
    """
    for i in range(1, len(blk) - p1):
        if blk[p0:p0+i] != blk[p1:p1+i]:
            return i - 1
    return len(blk) - p1 - 1