a, b, c, d = list(map(int, input().split()))

if max(a, c) > min(b, d):

    print((0))

else:

    print((-max(a, c)+min(b, d)))

a, b, c, d = list(map(int, input().split()))

e = max(a, c)

f = min(b, d)

if e >= f:

    print((0))

else:

    print((abs(e-f)))

a, b, c, d = list(map(int, input().split()))
if max(a, c) > min(b, d):
    print((0))
else:
    print((-max(a, c) + min(b, d)))

a, b, c, d = list(map(int, input().split()))
e = max(a, c)
f = min(b, d)
if e >= f:
    print((0))
else:
    print((abs(e - f)))

-if max(a, c) > min(b, d): +e = max(a, c) +f = min(b, d) +if e >= f: -    print((-max(a, c) + min(b, d))) +    print((abs(e - f)))