def _interval_overlap(interval_a, interval_b):
    (x1, x2) = interval_a
    (x3, x4) = interval_b
    if (x3 < x1):
        if (x4 < x1):
            return 0
        else:
            return (min(x2, x4) - x1)
    elif (x2 < x3):
        return 0
    else:
        return (min(x2, x4) - x3)
def _interval_overlap(interval_a, interval_b):
    (x1, x2) = interval_a
    (x3, x4) = interval_b
    if (x3 < x1):
        if (x4 < x1):
            return 0
        else:
            return (min(x2, x4) - x1)
    elif (x2 < x3):
        return 0
    else:
        return (min(x2, x4) - x3)