def overlap_size(v1, v2, u1, u2):
    """
    Calculate overlap size of intervals (v1, v2) and (u1, u2)
    """
    alen = abs(v1 - v2)
    blen = abs(u1 - u2)
    wide = max(v1, v2, u1, u2) - min(v1, v2, u1, u2)
    return alen + blen - wide
