Problem:
 Score : 200 points    Problem Statement Alice and Bob are controlling a robot. They each have one switch that controls the robot. Alice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up. Bob started holding down his button C second after the start-up, and released his button D second after the start-up. For how many seconds both Alice and Bob were holding down their buttons?      Constraints  0≤A<B≤100  0≤C<D≤100  All input values are integers.         Input Input is given from Standard Input in the following format:  A  B  C  D       Output Print the length of the duration (in seconds) in which both Alice and Bob were holding down their buttons.        Sample Input 1 0 75 25 100      Sample Output 1 50  Alice started holding down her button 0 second after the start-up of the robot, and released her button 75 second after the start-up. Bob started holding down his button 25 second after the start-up, and released his button 100 second after the start-up. Therefore, the time when both of them were holding down their buttons, is the 50 seconds from 25 seconds after the start-up to 75 seconds after the start-up.       Sample Input 2 0 33 66 99      Sample Output 2 0  Alice and Bob were not holding their buttons at the same time, so the answer is zero seconds.       Sample Input 3 10 90 20 80      Sample Output 3 60

Solution (Python):
a,b,c,d=map(int, input().split())
ans=min(d-a, b-c, d-c, b-a)
print(max(ans,0))

Solution (Python):
A, B, C, D = [int(i) for i in input().split()]

t1 = max(A, C)
t2 = min(B, D)

print(max(0, t2 - t1))

Solution (Python):
def answer(a: int, b: int, c: int, d: int) -> int:
    return len(set(range(a, b)) & set(range(c, d)))


def main():
    a, b, c, d = map(int, input().split())
    print(answer(a, b, c, d))


if __name__ == '__main__':
    main()

Solution (Python):
def answer(a: int, b: int, c: int, d: int) -> int:
    return max(0, min(b, d) - max(a, c))


def main():
    a, b, c, d = map(int, input().split())
    print(answer(a, b, c, d))


if __name__ == '__main__':
    main()

Solution (Python):
a,b,c,d = map(int, input().split())

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

Solution (Python):
A, B, C, D = map(int, input().split())

M1 = max(A, C)
M2 = min(B, D)

M = M2 - M1

if M > 0:
    print(M)

else:
    print(0)

Solution (Python):
a, b, c, d = map(int, input().split())
print(max(0, min(b, d) - max(a, c)))

Solution (Python):
a,b,c,d = map(int,input().split())
if b <= c or d <= a:
  print(0)
elif a <= c:
  print(min(b,d)-c)
elif a >= c:
  print(min(b,d)-a)

Solution (Python):
A, B, C, D = list(map(int, input().split()))
if A <= C:
    if B <= D:
        if B - C <= 0:
            print(0)
        else:
            print(B - C)
    else:
        if D - C <= 0:
            print(0)
        else:
            print(D - C)
else:
    if B <= D:
        if B - A <= 0:
            print(0)
        else:
            print(B - A)
    else:
        if D - A <= 0:
            print(0)
        else:
            print(D - A)

Solution (Python):
a, b, c, d = map(int, input().split())
e = 0
f = 0
if a < c:
  e = c
else:
  e = a
if b < d:
  f = b
else:
  f = d
if e <= f:
  print(f-e)
else:
  print(0)

Solution (Python):
lst = input().split()

A = int(lst[0])
B = int(lst[1])
C = int(lst[2])
D = int(lst[3])

if (B <= C) or (D <= A):
   print(0)
elif (A <= C <= B) and (C <= B <= D):
   print(B - C)
elif (C <= A <= D) and (A <= D <= B):
   print(D - A)
else:
   print(min([B - A, D - C]))

Solution (Python):
a,b,c,d = map(int,input().split())
if b <= c or d <= a:
    print(0)
elif  a <= c:
    if b <= d:
        print(b - c)
    else:
        print(d - c)
else:
    if b <= d:
        print(b - a)
    else:
        print(d - a)

Solution (Python):


A,B,C,D = map(int, input().split())

start = max(A,C)
end = min(B,D)
ans = max(end - start, 0)
print(ans)

Solution (Python):
a, b, c, d = map(int, input().split())
if a > c: a, b, c, d = c, d, a, b
if b < c: print(0)
elif b < d: print(b - c)
else: print(d - c)

Solution (Python):
a, b, c, d = map(int, input().split())

print(min (b, d) - max(a, c)) if min (b, d) > max(a, c) else print(0)

Solution (Python):
a, b, c, d = map(int, input().split())
print(max(0, min(b, d) - max(a, c)))

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))

Solution (Python):
A, B, C, D = map(int, input().split())
x = min(B, D) - max(A, C)
print(x) if x > 0 else print(0)

Solution (Python):
A, B ,C ,D = map(int, input().split())

a = list(range(A, B))
b = list(range(C, D))

a_b_and = set(a) & set(b)
print(len(a_b_and))

Solution (Python):
A, B, C, D = map(int, input().split())

if A<=C and D<=B: 
    print(D-C)
    exit()

if C<=A and B<=D: 
    print(B-A)
    exit()


if (A<=C and C<= B and B<=D): 
    print(B-C)
    exit()

if C<=A and A<=D and D<=B: 
    print(D-A)
    exit()

if B<=C or D<=A: 
    print(0)
    exit()

Solution (Python):
A, B, C, D = map(int, input().split())

mint = max(A, C)
maxt = min(B, D)

dt = max(0, maxt - mint)
print(dt)

Solution (Python):
A, B, C, D = map(int, input().split())

alice = [1 if A <= t < B else 0 for t in range(0, 110)]
bob = [1 if C <= t < D else 0 for t in range(0, 110)]

overlap = [1 for a, b in zip(alice, bob) if a > 0 and b > 0]

print(len(overlap))

Solution (Python):
import re
import copy

def accept_input():
    ast,aen,bst,ben = map(int, input().split())
    return ast,aen,bst,ben

def process(s):
    if s == "
        return 1
    else:
        return 0
ast,aen,bst,ben = accept_input()

if ast >= bst and ast <= ben:
    print(min(ben,aen)-ast)
elif ast < bst:
    if aen < bst:
        print(0)
    else:
        print(min(aen,ben)-bst)
else:
    print(0)

Solution (Python):
with open(0) as f:
    a, b, c, d = map(int, f.read().split())
f = lambda x: 0 if x < 0 else x
print(f(min(b, d) - max(a, c)))

Solution (Python):
A,B,C,D=map(int,input().split())
print(max(0,min(B,D)-max(A,C)))

Solution (Python):
a,b,c,d=input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
if c<a<d:
  if b>d:
    print(d-a)
  else:
    print(b-a)
if a<=c:
  if b<c:
    print(0)
  elif c<=b<=d:
    print(b-c)
  else:
    print(d-c)
if a>=d:
  print(0)

Solution (Python):
A, B, C, D = map(int, input().split())
if C>=B or A>=D:
    print(0)
elif C>=A:
    if D >= B:
        print(B-C)
    else:
        print(D-C)
elif A > C:
    if D >= B:
        print(B-A)
    else:
        print(D-A)

Solution (Python):
a,b,c,d=map(int,input().split())
x=max(a,c)
y=min(b,d)
if 0<(y-x):
    print(y-x)
else:
    print(0)

Solution (Python):
import numpy as np

A, B, C, D = map(int,input().split())

a = [0 for _ in range(100)]
b = [0 for _ in range(100)]

a[A:B] = [1 for _ in range(B - A)]
b[C:D] = [1 for _ in range(D - C)]

c = np.array(a) * np.array(b)

print(c.sum())

Solution (Python):
a, b, c, d = map(int, input().split())
print(max(min(b, d) - max(a, c), 0))

Solution (Python):
a, b, c, d = map(int, input().split())
if a < c:
        if b < c:
                print(0)
        if c <= b <= d:
                print(abs(b-c))
        if d < b:
                print(abs(d-c))
if c <= a:
        if d < a:
                print(0)
        if a <= d <= b:
                print(abs(d-a))
        if b < d:
                print(abs(b-a))

Solution (Python):
a, b, c, d = map(int, input().split())
if b < c or d < a:
    print(0)
elif a <= c and d <= b:
    print(d-c)
elif c <= a and b <= d:
    print(b-a)
elif a <= c and b <= d:
    print(b-c)
elif c <= a and d <= b:
    print(d-a)

Solution (Python):
A, B, C, D = map(int, input().split())
print(max(min(B, D) - max(A, C), 0))

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(min(b,d)-max(a,c),0))

Solution (Python):
a, b, c, d = map(int, input().split())
aa = [0 for i in range(101)]
bb = [0 for i in range(101)]
ans = 0
for i in range(a, b):
    aa[i] = 1
for i in range(c, d):
    bb[i] = 1
for i in range(101):
    if aa[i] == 1 and bb[i] == 1:
        ans += 1
print(ans)

Solution (Python):
a,b,c,d = map(int,input().split())
print(max(0, min(b,d) - max(a,c)))

Solution (Python):
A, B, C, D=map(int, input().split())
X=set([i for i in range(A, B)])
print(sum([1 for i in range(C, D) if i in X]))

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

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

Solution (Python):
a,b,c,d=list(map(int, input().split()))
print(max(min(b,d)-max(a,c),0))

Solution (Python):
a,b,c,d=map(int,input().split())
if b<=c or d<=a:
    print('0')
elif b<=d:
    print(min(b-c,b-a))
else:
    print(min(d-a,d-c))

Solution (Python):

import sys


def solve(A: int, B: int, C: int, D: int):
    s = max(A, C)
    e = min(B, D)
    print(max(e - s, 0))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    C = int(next(tokens))  
    D = int(next(tokens))  
    solve(A, B, C, D)


if __name__ == "__main__":
    main()

Solution (Python):
a,b,c,d = map(int,input().split())

s1 = set(range(a,b+1))
s2 = set(range(c,d+1))


print(max(len(s1 & s2)-1,0))

Solution (Python):
A,B,C,D = map(int, input().split())

if (C<A and D<=A) or (B<=C and C<D):
    time = 0
else:
    if A<=C and D<=B:
        time = D-C
    elif C<=A and B<=D:
        time = B-A
    elif C<=A and D<=B:
        time = D-A
    elif A<=C and B<=D:
        time = B-C
print(time)

Solution (Python):
a,b,c,d=map(int,input().split())
ans=0
for i in range(201):
    if a<=i<b and c<=i<d:
        ans+=1
print(ans)

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

Solution (Python):
a,b,c,d=map(int,input().split())
if b<c or d<a:
    print(0)
else:
    if a<=c:
        if b<=d:
            print(b-c)
        else:
            print(d-c)
    else:
        if d<=b:
            print(d-a)
        else:
            print(b-a)

Solution (Python):

url = "https://atcoder.jp//contests/abc070/tasks/abc070_b"

def main():
    t = list(map(int, input().split()))
    start = max(t[0], t[2])
    end = min(t[1], t[3])
    if end >= start:
        print(end - start)
    else:
        print(0)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
a, b, c, d = map(int, input().split())
if b<=c or d<=a:
    print(0)
    sys.exit()
print(min(b,d) - max(a,c))

Solution (Python):
A,B,C,D=map(int,input().split())
if A<C and B>=D :
  res=D-C
elif A>=C and B>=D :
  res=D-A
elif A<C and B<D :
  res=B-C
else :
  res=B-A
if res<=0 :
  print(0)
else :
  print(res)

Solution (Python):
a,b,c,d = map(int, input().split())

if (b<=c)|(d<=a):
    print(0)
else:
    if (a<=c)&(b<=d):
        print(b-c)
    elif (c<=a)&(d<=b):
        print(d-a)
    else:
        print(min(d-c,b-a))

Solution (Python):
a, b, c, d = map(int, input().split())


ans = 0

if b <= c or d <= a:
    ans = 0
else:
    ans = min(d, b) - max(a, c)

print(ans)

Solution (Python):
a,b,c,d = map(int,input().split())
if b < c:
  print(0)
  exit()
print(max(0, min(d,b)-max(a,c)))

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, d = map(int, readline().split())

    ans = max(0, min(b, d) - max(a, c))

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
A, B, C, D = map(int, input().split())

ans = 0
for i in range(100):
    if A <= i < B and C <= i < D:
        ans += 1

print(ans)

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))

Solution (Python):
A, B, C, D = map(int, input().split())
print(max(min(B, D)-max(A, C), 0))

Solution (Python):
a,b,c,d = map(int, input().split())
alice = set(i for i in range(a,b+1))
bob = set(j for j in range(c,d+1))
s = alice & bob
print(max(len(alice & bob) - 1, 0))

Solution (Python):
a,b,c,d=map(int,input().split())
e=max(a,c)
f=min(b,d)
if e<f:
  print(f-e)
else:
  print(0)

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def main():
    a,b,c,d = MII()
    print(max(min(b,d)-max(a,c), 0))

if __name__ == '__main__':
    main()

Solution (Python):
A, B, C, D = map(int, input().split())

bottom = max(A, C)
top = min(B, D)

if top - bottom > 0:
    print(top - bottom)
else:
    print(0)

Solution (Python):
A, B, C, D = map(int, input().split())

print(max(0, min(B, D)-max(A, C)))

Solution (Python):
a, b, c, d = (int(x) for x in input().split())

if a <= c <= b:
    if d <= b:
        print(d-c)
    else:
        print(b-c)
elif c <= a:
    if b <= d:
        print(b-a)
    elif a <= d <= b:
        print(d-a)
    else:
        print(0)
else:
    print(0)

Solution (Python):
A,B,C,D=map(int,input().split())
if B<C or D<A:
    print(0)
elif D>=B and A>=C:
    print(B-A)
elif D>B:
    print(B-C)
elif B>=D and C>=A:
    print(D-C)
else:
    print(D-A)

Solution (Python):
a, b, c, d = map(int, input().split())
s = max(a, c)
e = min(b, d)
print(e - s if e-s > 0 else 0)

Solution (Python):
a, b, c, d = map(int, input().split())

if b <= c or d <= a:
    print(0)
elif a <= c and d <= b:
    print(d - c)
elif c <= a and b <= d:
    print(b - a)
elif a <= c:
    print(b - c)
else:
    print(d - a)

Solution (Python):
LI = lambda: list(map(int, input().split()))

A, B, C, D = LI()


def main():
    x = max(A, C)
    y = min(B, D)
    ans = max(0, y - x)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    a, b, c, d = map(int, input().split())
    print(max(0, min(b, d) - max(a, c)))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    a, b, c, d = map(int, input().split())
    print(max(0, min(b, d) - max(a, c)))


if __name__ == '__main__':
    main()

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(0,min(b-c,d-a,b-a,d-c)))

Solution (Python):
A,B,C,D=map(int,input().split())
if A<=C:
  if D>=B:
    t=B-C
  else:
    t=D-C
else:
  if D>=B:
    t=B-A
  else:
    t=D-A
if t<=0:
  print(0)
else:
  print(t)

Solution (Python):
a, b, c, d = map(int, input().split())
print(max(0, min(b, d) - max(a, c)))

Solution (Python):
l=list(map(int,input().split()))
print(max(0,min(l[1],l[3])-max(l[0],l[2])))

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))

Solution (Python):
a, b, c, d = map(int, input().split())
print(max(0, min(b, d) - max(a, c)))

Solution (Python):
a,b,c,d = map(int,input().split())

overlap = max(0,(min(b,d)-max(a,c)))
print(overlap)

Solution (Python):
a,b,c,d = map(int,input().split())
if b <= d and a <= c:
	print(max(b-c,0))
elif b <= d and a > c:
	print(max(b-a,0))
elif b > d and a <= c:
	print(max(d-c,0))
else:
	print(max(d-a,0))

Solution (Python):
a,b,c,d=map(int,input().split())

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

Solution (Python):
A, B, C, D = map(int, input().split())

print(max(min(B, D)-max(A, C), 0))

Solution (Python):
a, b, c, d = map(int, input().split())

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

Solution (Python):
A,B,C,D = map(int,input().split())

s = max(A,C)
e = min(B,D)

print(e-s if e-s>0 else 0)

Solution (Python):
a, b, c, d = list(map(int, input().split()))
if d <= a:
    print(0)
    exit()
if a <= c <= b:
    if b >= d:
        print(d - c)
        exit()
    else:
        print(b - c)
        exit()
elif c < a:
    if b >= d:
        print(d - a)
        exit()
    else:
        print(b - a)
        exit()
else:
    print(0)

Solution (Python):

A, B, C, D = map(int, input().split())
if min(B, D) >= max(A, C):
    print(min(B, D) - max(A,C))
else:
    print(0)

Solution (Python):
l = list(map(int,input().split()))

if l[1] < l[2]:
    print(0)
elif l[0] > l[3]:
    print(0)
else:
    l.sort()
    print(l[2]-l[1])

Solution (Python):
A, B, C, D = map(int, input().split())
init = max(A, C)
end = min(B, D)
print(end-init if init < end else 0)

Solution (Python):
a,b,c,d = map(int, input().split())
x=[0]*101
cnt=0
for i in range(a,b+1):
    x[i]=1
for i in range(c,d+1):
    if x[i]==1:
        cnt+=1
if cnt==0:
    print(cnt)
else:
    print(cnt-1)

Solution (Python):
A,B,C,D=map(int,input().split())
if C<=A and A<=D and D<=B:
    print(D-A)
elif C<=A and B<=D:
    print(B-A)
elif A<=C and C<=B and B<=D:
    print(B-C)
elif A<=C and D<=B:
    print(D-C)
else:
    print(0)

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

Solution (Python):
a,b,c,d=map(int,input().split())

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

Solution (Python):
a, b, c, d =map(int,input().split())
ans = max(min(b, d) - max(a, c), 0)
print(ans)

Solution (Python):
a, b, c, d = map(int, input().split())

if  a < c < b and c < b < d:
    print(b-c)
elif c < a < d and a < d < b:
    print(d-a)
elif a < c < d < b:
    print(d-c)
elif c < a < b < d:
    print(b-a)
elif a == c:
    print(min(b, d))
elif b == d:
    print(min(b-a,d-c))
else:
    print(0)

Solution (Python):
t = [0] * 101

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

for i in range(a, b):
    t[i] += 1
for j in range(c, d):
    t[j] += 1
print(t.count(2))

Solution (Python):
import math
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7





A, B, C, D = LI()

if B <= C or D <=A:
    ans = 0
elif C <= A and B <= D:
    ans = B - A
elif A<=C and D<=B:
    ans = D - C
elif A<=C and B<=D:
    ans = B-C
elif C<=A and D<=B:
    ans = D-A
else:
    ans = 'error'

print(ans)

Solution (Python):
a, b, c, d = map(int, input().split())
s = max(a, c)
e = min(b, d)
print(e - s if e - s > 0 else 0)

Solution (Python):
a, b, c, d = map(int, input().split())
if b < c or a > d:
    print('0')
elif a <= c and b >= d:
    print(d - c)
elif a >= c and b <= d:
    print(b - a)
elif b < d:
    print(b - c)
elif b > d:
    print(d - a)

Solution (Python):
A,B,C,D=map(int,input().split())
ali='0'*101
bob='0'*101
ali=ali[:A]+'1'*(B-A)+ali[B+1:]
bob=bob[:C]+'1'*(D-C)+bob[D+1:]
ans=int(ali,2)&int(bob,2)
print(bin(ans).count('1'))

Solution (Python):
a,b,c,d=map(int,input().split());print(max(0,min(b,d)-max(a,c)))

Solution (Python):
a,b,c,d=map(int,input().split());r=min(b,d)-max(a,c);print([0,r][r>0])

Solution (Python):
A,B,C,D=map(int,input().split())
start=max(A,C)
end=min(B,D)

print(end-start if end-start>0 else 0)

Solution (Python):
a,b,c,d = map(int,input().split())
if b<=c or d<=a:
    print(0)
    exit()
print(abs(max(a,c)-min(b,d)))

Solution (Python):
A,B,C,D = map (int, input ().split ())
if A < C:
  X = C
else:
  X = A
if B < D:
  Y = B
else:
  Y = D
if Y-X < 0:
  print (0)
else:
  print (Y-X)

Solution (Python):
A,B,C,D = map(int,input().rstrip().split(" "))
print(max(min(B,D) - max(A,C),0))

Solution (Python):
def main():
    A, B, C, D = map(int, input().split())

    ans = max(0, min(B, D) - max(A, C))
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    A, B, C, D = map(int, input().split())

    if D <= A or B <= C:
        ans = 0
    if C <= A and A <= D:
        ans = D - A
    if C <= B and B <= D:
        ans = B - C
    if A <= C and D <= B:
        ans = D - C
    if C <= A and B <= D:
        ans = B - A
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

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



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

Solution (Python):
A, B, C, D = map(int,input().split())
print(max(0,min(B,D)-max(A,C)))

Solution (Python):
A, B, C, D = map(int, input().split())

a = []
for i in range(A, B):
    a.append(i)

b = []
for  i in range(C, D):
    b.append(i)

ans = 0
for i in a:
    if i in b:
        ans += 1

print(ans)

Solution (Python):



import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """0 75 25 100"""
        output = """50"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """0 33 66 99"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10 90 20 80"""
        output = """60"""
        self.assertIO(input, output)


def resolve():
    A, B, C, D = map(int, input().split())

    if A > C:
        A, C = C, A
        B, D = D, B

    if B < D:
        print(max(0, B-C))
    else:
        print(D-C)


if __name__ == "__main__":
    
    resolve()

Solution (Python):

A,B,C,D=map(int,input().split())

print(max(min(B,D)-max(A,C),0))

Solution (Python):
A, B, C, D = map(int, input().split(' '))
answer = min(B,D)-max(A,C) 
if answer < 0:
  answer = 0
print(answer)

Solution (Python):
A, B, C, D = map(int, input().split(' '))
answer = 0
if A <= C and B <= D:
  answer = B-C
if A <= C and B >D:
  answer = D-C
if A > C and B <= D:
  answer = B-A
if A > C and B > D:
  answer = D-A
if answer < 0:
  answer = 0
print(answer)

Solution (Python):
A, B, C, D = map(int, input().split())
print(max(0, min(B, D) - max(A, C)))

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

Solution (Python):
a, b, c, d = map(int, input().split())

if b <= c or d <= a:
    ans = 0
elif a < c and c < b and b < d:
    ans = abs(b-c)
elif c < a and a < d and d < b:
    ans = abs(d-a)
elif a <= c and d <= b:
    ans = abs(d-c)
else:
    ans = b-a

print(ans)

Solution (Python):
A, B, C, D = map(int, input().split())
print(max(0, min(B, D)-max(A, C)))

Solution (Python):
A, B, C, D = map(int, input().split())
if B <= C or D <= A:
    print(0)
else:
    print(min(B-A, D-A, B-C, D-C))

Solution (Python):
a,b,c,d = map(int, input().split())
alice = list(range(a,b+1))
bob = list(range(c,d+1))
ab = alice + bob
l= [i for i in set(ab) if ab.count(i) > 1]
if 0 == len(l) or 1 == len(l):
    print(0)
elif 2 == len(l):
    print(1)
else:
    print(max(l) - min(l))

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))

Solution (Python):
a, b, c, d = map(int,input().split())

if max(a,c) < min(b,d):
    print(min(b,d)-max(a,c))
else:
    print(0)

Solution (Python):
a, b, c, d = map(int, input().split())
print(0) if b <= c or d <= a else print(min(d-a, b-c, b-a, d-c))

Solution (Python):
a,b,c,d = map(int,input().split())
if b<=c or d<=a:
    print(0)
elif a<=c<=d<=b:
    print(d-c)
elif c<=a<=b<=d:
    print(b-a)
elif a<=c<=b<=d:
    print(b-c)
elif c<=a<=d<=b:
    print(d-a)

Solution (Python):
a,b,c,d=map(int,input().split())
n = max(a,c)
m = min(b,d)
if(m<=n):print(0);exit()
else:print(m-n)

Solution (Python):
A,B,C,D=map(int,input().split())
s=min(B,D)-max(A,C)
if s<0:
  print(0)
else:
  print(s)

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, c, d = rm()
max_ = max(a, c)
min_ = min(b, d)
print(max(0, min_ - max_))

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A, B, C, D = LI()

    ans = max(min(B, D) - max(A, C), 0)
    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):
a,b,c,d=map(int,input().split())

def seconds(a,b,c,d):
  if b<=c or d<=a:
    print(0)
    return
  else:
    st=max(a,c)
    go=min(b,d)
    print(go-st)
    return

seconds(a,b,c,d)

Solution (Python):
A,B,C,D=map(int,input().split())
if C<=A and B<=D:
  print(B-A)
elif C<D<=A<B:
  print(0)
elif C<=A and D<=B:
  print(D-A)
elif B-C>=0 and B<=D:
  print(B-C)
elif B-C>=0 and B>=D:
  print(D-C)
else:
  print(0)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, C, D = map(int, readline().split())
    start = max(A, C)
    end = min(B,D)
    print(max(end-start,0))

if __name__ == '__main__':
    main()

Solution (Python):
a, b, c, d = map(int, input().split())
start = max(a, c)
end = min(b, d)
ans = end - start if start <= end else 0
print(ans)

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, c, d = M()
print(max(min(b, d) - max(a, c), 0))

Solution (Python):
a, b, c, d = map(int, input().split(" "))

if a <= c:
  if b <= c:
    ans = 0
  elif d <= b:
    ans = d - c
  else:
    ans = b - c
else:
  if d <= a:
    ans = 0
  elif b <= d:
    ans = b - a
  else:
    ans = d - a
print(ans)

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))

Solution (Python):
A, B, C, D = list(map(lambda t: int(t), input().split(" ")))
 
if B - A + D - C <= max([D - A, B - C]):
  print(0)
else:
  print(min([B, D]) - max([A, C]))

Solution (Python):
A,B,C,D = map(int,input().split())
N = min(B,D)-max(A,C)
if N <= 0:
  print(0)
else:
  print(N)

Solution (Python):









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

top = min(b,d)
down = max(a,c)

print(max(0, top-down))

Solution (Python):
a, b, c, d = map(int, input().split())

if d <= a or b <= c:
  print(0)
elif c <= a and b <= d:
  print(b-a)
elif a <= c and b <= d:
  print(b-c)
elif c <= a and d <= b:
  print(d-a)
elif a <= c and d <= b:
  print(d-c)
else:
  print(0)

Solution (Python):
a, b, c, d = map(int, input().split())
if min(b, d) < max(a, c):
    print(0)
else:
    print(min(b, d)-max(a, c))

Solution (Python):
a, b, c, d = map(int, input().split())
print(0 if min(b, d)-max(a, c) < 0 else min(b, d)-max(a, c))

Solution (Python):
A,B,C,D = map(int, input().split())

Time = min(B,D) - max(A,C)

print(max(0, Time))

Solution (Python):
a,b,c,d=map(int,input().split())



if b>=c and d>=a:
    print((min(b,d)-max(a,c)))
else:
    print(0)

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(min(b,d)-max(a,c),0))

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(min(b,d)-max(a,c),0))

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(min(b,d)-max(a,c),0))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


def main():
    a, b, c, d = map(int, input().split())
    print(max(0, min(b, d) - max(a, c)))

if __name__ == "__main__":
    main()

Solution (Python):
a,b,c,d = map(int,input().split())
ans = min(b,d) - max(a,c)
print(max(0,ans))

Solution (Python):
A, B, C, D = map(int, input().split())
print(max(min(B, D) - max(A, C), 0))

Solution (Python):
a,b,c,d=map(int,input().split())
if c<b<=d:
    print(b-max([a,c]))
elif a<d<b:
    print(d-max([a,c]))
else:
    print(0)

Solution (Python):
A,B,C,D = map(int,input().split())
lower = max(A,C)
upper = min(B,D)
print(max(upper-lower,0))

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

Solution (Python):
a,b,c,d = map(int,input().split())
figs = [a,b,c,d]
new_figs = sorted(figs)

if b<c or a>d:
    print(0)
    exit()

print(new_figs[2]-new_figs[1])

Solution (Python):
A,B,C,D = map(int,input().split())

if min(B,D)<max(A,C):
    print(0)
else:
    print(min(B,D)-max(A,C))

Solution (Python):
A,B,C,D=map(int,input().split())
start=max(A,C)
end=min(B,D)

print(end-start if start<end else 0)

Solution (Python):
A,B,C,D = (int(T) for T in input().split())
print(max(0,min(B,D)-max(A,C)))

Solution (Python):
A,B,C,D=map(int,input().split())

print(max(min(B,D)-max(A,C),0))

Solution (Python):
a,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, C, D = map(int, readline().split())

    lower = max(A, C)
    upper = min(B, D)
    ans = max(upper - lower, 0)

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, C, D = map(int, readline().split())

    if B < C or D < A:
        ans = 0
    elif C > A:
        if D < B:
            ans = D - C
        else:
            ans = B - C
    else:
        if D < B:
            ans = D - A
        else:
            ans = B - A

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
a,b,c,d=map(int,input().split())
lower=max(a,c)
upper=min(b,d)
ans=upper - lower
if ans<0:
  ans=0
print(ans)

Solution (Python):
a,b,c,d=map(int,input().split())
ans=0

if a <= c:
  if b <= c:
    pass
  elif b <= d:
    ans = b-c
  else:
    ans = d-c
else:
  if d <= a:
    pass
  elif d <= b:
    ans = d-a
  else:
    ans = b-a
print(ans)

Solution (Python):
a, b, c, d = map(int, input().split())
table = [0] * 101

for i in range(a, b):
    table[i] += 1

for j in range(c, d):
    table[j] += 1

print(table.count(2))

Solution (Python):
a, b, c, d = map(int, input().split())
table = [0] * 101

for i in range(a, b+1):
    table[i] += 1

for j in range(c, d+1):
    table[j] += 1

print(table.count(2) if table.count(2) == 0 else table.count(2)-1)

Solution (Python):
a, b, c, d = map(int, input().split())
al = [x for x in range(a,b)]
cl = [y for y in range(c,d)]

print(len(al+cl)-len(set(al+cl)))

Solution (Python):
a, b, c, d = map(int, input().split())
if a < c:
  if b < c:
    print(0)
  elif d > b:
    print(b-c)
  else:
    print(d-c)
else:
  if a > d:
    print(0)
  elif b > d:
    print(d-a)
  else:
    print(b-a)

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    a,b,c,d = map(int, input().split())

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


if __name__ == '__main__':
    main()