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())
if C<=B<=D:
    if A<C: print(B-C)
    else: print(B-A)
elif A<=D<=B:
    if C<A: print(D-A)
    else: print(D-C)
else:
    print(0)

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

Solution (Python):
A,B,C,D = map(int,input().split())
alice = []
bob = []
ans = 0
for i in range(A,B):
  alice.append(i)
for j in range(C,D):
  bob.append(j)
for _ in range(0,100):
  if _ in alice and _ in bob:
    ans += 1
print(ans)

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

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

Solution (Python):
A = list(map(int,input().split()))
if A[1] <= A[2] or A[3] <= A[0]:
    print(0)
else:
    A.sort()
    print(A[2]-A[1])

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

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

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

Solution (Python):
a,b,c,d = map(int,input().split())
x = set(range(a,b)) & set(range(c,d))
print(len(x))

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())
print(max(0, min(b, d) - max(a, c)))

Solution (Python):
a, b, c, d = map(int, input().split())
start = max(a, c)
stop = min(b, d)
val = stop - start

if val <= 0:
    print(0)
elif val > 0:
    print(val)

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

if b<=c or d<=a:
  print(0)
else:
  print(min(b,d)-max(a,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 0)

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

Solution (Python):
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
a,b,c,d = na()

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

Solution (Python):
import sys
import math
from fractions import gcd





def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""


 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())


 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


A, B, C, D = map(int, sys.stdin.readline().split())

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

Solution (Python):
A,B,C,D = map(int,input().split())
if D <= A or B <= C:
    print(0)
else:
    print(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:
    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):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    a,b,c,d=map(int,input().split())
    print(max(0,min(d,b)-max(a,c)))
resolve()

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

Solution (Python):
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B, C, D = map(int, input().split())
        print(max(min(B, D) - max(A, C), 0))



if __name__ == '__main__':
    AtCoder().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())

left = max(a, c)
right = min(b, d)

print(max(right - left, 0))

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

if C <= A:
    if D <= A:
        result = 0
    elif A <= D and D <= B:
        result = D - A
    else:
        result = B - A
elif A <= C and C <= B:
    if D <= B:
        result = D - C
    else:
        result = B - C
else:
    result = 0

print(result)

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

if a<c:
    if b>c:
        if b>d:
            answer=d-c
        else:
            answer=b-c
else:
    if d>a:
        if d>b:
            answer=b-a
        else:
            answer=d-a
print(answer)

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

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

ans=[0]*101
for i in range(a,b):
    ans[i]+=1
for i in range(c,d):
    ans[i]+=1
    
kai=0
for i in range(101):
    if ans[i]==2:
        kai+=1
print(kai)

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


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

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

start = C if A < C else A
end = B if B < D else D
ans = 0 if start > end else end - start
print(ans)

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

start = max(a, c)
end = min(b, d)
time = 0
if start < end:
    time = end - start

print(time)

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

Alice_list = []
Bob_list = []

def fill_list(AB_list, starting, ending):
    for idx in range(101):
        if idx < starting:
            AB_list.append(0)
        elif starting <= idx < ending:
            AB_list.append(1)
        else:
            AB_list.append(0)

fill_list(Alice_list, A, B)
fill_list(Bob_list, C, D)

print([x+y for (x,y) in zip(Alice_list,Bob_list)].count(2))

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

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

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:
    print(0)
elif A <= C <= B and B <= D:
    print(B-C)
elif A <= C and D <= B:
    print(D-C)
elif C <= A and A <= D <= B:
    print(D-A)
elif D <= A:
    print(0)
elif C <= A and B <= D:
    print(B-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())
ans=min(b,d)-max(a,c)
if ans < 0:
    ans=0
print(ans)

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

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

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

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

Solution (Python):
A,B,C,D = map(int, input().split())
Alice = [0]*(A) + [1]*(B-A) + [0]*(101-B)
Bob = [0]*(C) + [1]*(D-C) + [0]*(101-D)
print(sum([i*j for i,j in zip(Alice,Bob)]))

Solution (Python):
a,b,c,d=map(int,input().split());print(max(0,min(b-a,d-a,b-c,d-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(min(b,d) - max(a,c) if min(b,d) - max(a,c) >= 0 else 0)

Solution (Python):
a, b, c, d = map(int, input().split())
count = 0
for i in range(max(a, c), min(b, d)):
    count += 1
print(count)

Solution (Python):


def min(a, b):
	if a > b:
		return b
	else:
		return a

def max(a, b):
	if a > b:
		return a
	else:
		return b



def main():
	linie = input()
	vector = [int(x) for x in linie.split()]
	time = (-1) * (max(vector[2], vector[0]) - min(vector[1], vector[3]))
	if time < 0:
		print(0)
	else:
		print(time)




if __name__ == "__main__":
	main()

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

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

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

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=0
e=0

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

if a <= c:
    s=c
else:
    s=a

if b <= d:
    e=b
else:
    e=d

print(e-s)

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):
A,B,C,D=map(int,input().split())
 
if B<=C or D<=A:
    print(0)
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)
elif C<=A and B<=D:
    print(B-A)

Solution (Python):
import sys
input = sys.stdin.readline

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()))


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

Solution (Python):
s = input().split()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])

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

Solution (Python):
array = list(map(int, input().split()))
A = array[0]
B = array[1]
C = array[2]
D = array[3]

if A >= C:
    start = A
else:
    start = C

if B >= D:
    end = D
else:
    end = B

ans = end - start

if ans < 0:
    print(0)
else:
    print(ans)

Solution (Python):


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

if B<=C or D<=A:
    print(0)
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)
elif C<=A and B<=D:
    print(B-A)

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

start = 0
end = 0

if a >= c:
    start = a
else:
    start = c

if b <= d:
    end = b
else:
    end = d

time = end-start

if time > 0:
    print(time)
else:
    print(0)

Solution (Python):

A, B, C, D = map(int, input().split())
time = [0 for i in range(100)]
for i in range(A, B):
    time[i] += 1
for i in range(C, D):
    time[i] += 1
ans = 0
for i in range(len(time)):
    if time[i] == 2:
        ans += 1
print(ans)

Solution (Python):


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

if A < C:
    start = C
else:
    start = A

if B < D:
    end = B
else:
    end = D

answer = end - start
if answer > 0:
    print(answer)
else:
    print(0)

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

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

print(min(b, d)-max(a, c) if min(b, d)-max(a, c) > 0 else 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().strip().split(' '))
print(max(0, min(b,d) - max(a,c)))

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

if n[1] < n[2]:
    print(0)
elif n[3] < n[0]:
    print(0)
else:
    m = sorted(n)
    print(m[2]-m[1])

Solution (Python):

import sys


def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

A, B, C, D = ISI()
ans = 0
for i in range(1, 101):
    if A < i <= B and C < i <= D:
        ans += 1
print(ans)

Solution (Python):
A, B, C, D = map(int, input().split())
sec = 0
for i in range(1, 101):
    if A < i <= B and C < i <= D:
        sec += 1
print(sec)

Solution (Python):
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

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

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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(min(B, D) - max(A, C) if min(B, D) > max(A, C) else 0)

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

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

Solution (Python):


import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Solution (Python):


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

if a <= c:
    kaishi = c
else:
    kaishi = a
    
if b <= d:
    shuryo = b
else:
    shuryo = d

if kaishi > shuryo:
    print(0)
else:
    print(shuryo - kaishi)

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


if __name__ == "__main__":
    test()

Solution (Python):
line = input().split()
a,b,c,d = int(line[0]),int(line[1]),int(line[2]),int(line[3])

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

else:
    base1 = max([a,c])
    base2 = min([b,d])
    print(base2-base1)

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

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

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

Solution (Python):

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

result = 0

if B <= C or D <= A:
    print(result)
    exit()
if A <= C :
    if B >= D:
        result = D-C
    if B < D:
        result = B-C
if A > C:
    if B >=D:
        result = D-A
    if B <D:
        result = B-A

print(result)

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())
arr=[0]*101

for i in range(0,101):
    if i>=A and i<=B:
        arr[i]+=1
    if i>=C and i<=D:
        arr[i]+=1
ans=arr.count(2)
print(ans-1 if ans>1 else 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)
else:
  print(min(b,d)-max(a,c))

Solution (Python):


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

start_time = max(a, c)
stop_time = min(b, d)

if start_time > stop_time:
    print(0)
else:
    print(stop_time - start_time)

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

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())
if d <= a or b <= c: print(0)
elif a <= c and d <= b: print(d-c)
elif c <= a and b <= d: print(b-a)
elif c <= a and d <= b: print(d-a)
elif a <= c and b <= d: print(b-c)

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

Solution (Python):


def resolve():
    a, b, c, d = map(int, input().split())
    ans = 0
    if a <= c and b <= d:
        ans = b - c
    elif a <= c and d <= b:
        ans = d - c
    elif c <= a and b <= d:
        ans = b - a
    else:
        ans = d - a

    if ans < 0:
        print(0)
    else:
        print(ans)


if __name__ == "__main__":
    resolve()

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

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

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):
count = 0
A, B, C, D = map(int, input().split())
ALICE = list(range(A, B))
BOB = list(range(C, D))
for i in ALICE:
    if i in BOB:
        count += 1
print(count)

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

a = 0
for t in range(100):
    if A <= t < B and C <= t < D:
        a += 1
print(a)

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)
else:
    if b <= d:
        print(b - c)
    else:
        print(d - c)

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

start = max(A, C)
end = min(B, D)

print(max(end-start, 0))

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

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

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

Solution (Python):
def main():
    A, B, C, D = map(int, input().split())
    lv = [[A, B], [C, D]]
    lv.sort(key = lambda x:x[0])
    if lv[0][1] < lv[1][0]:
        return 0
    return min(lv[0][1], lv[1][1]) - lv[1][0]


if __name__ == '__main__':
    print(main())

Solution (Python):
def main():
    a, b, c, d = [int(i) for i in input().split()]
    print(min(b,d)-max(a,c) if min(b,d)-max(a,c)>0 else 0)


if __name__ == '__main__':
    main()

Solution (Python):
a, b, c, d = map(int, input().split())
ans = [0] * 100
for i in range(a, b):
    ans[i] += 1
for i in range(c, d):
    ans[i] += 1
print(len(list(filter(lambda x: x == 2, ans))))

Solution (Python):
a,b,c,d=map(int,input().split())
s=[]
for i in range(0,101):
  if a<=i<=b and c<=i<=d:
    s.append(i)
print(0 if len(s)==0 else max(s)-min(s))

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 = list(map(int, input().split()))
if(a <= c and c <= b and b <= d):
  print(b - c)
elif(c <= a and a <= b and b <= d):
  print(b - a)
elif(c <= a and a <= d and d <= b):
  print(d - a)
elif(a <= c and c <= d and d <= b):
  print(d - c) 
else:
  print(0)

Solution (Python):
num = [int(i) for i in input().split()]
set_ans = set(range(num[0], num[1]+1)) & set(range(num[2], num[3]+1))
if len(set_ans) == 0:
  print(0)
else:
  print(len(set_ans)-1)

Solution (Python):
start_a, stop_a, start_b, stop_b = map(int,input().split())

start = [start_a,start_b]
stop  = [stop_a, stop_b]

result = min(stop) - max(start)

if result < 0 :
    print(0)
else :print(result)

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

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

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

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 c <= a:
    print(min(d-a,b-a))
else:
    print(min(d-c,b-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 a<=c<=b<=d:
    print(b-c)
elif c<=a<=b<=d:
    print(b-a)
elif c<=a<=d<=b:
    print(d-a)

Solution (Python):
a,b,c,d=map(int, input().split())
if c-a>=0:
    if b-d>=0:
        print(d-c)
    elif b-c>=0:
        print(b-c)
    else:
        print(0)
else:
    if d-b>=0:
        print(b-a)
    elif d-a>=0:
        print(d-a)
    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 = list(map(int, input().split()))
print(str(max(min(A[1], A[3]) - max(A[0], A[2]), 0)))

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

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

Solution (Python):

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

count = 0
for i in range(d+1):
    if i == a:
        on_a = True
    if i == b:
        on_a = False
    if i == c:
        on_b = True
    if i == d:
        on_b = False

    if on_a and on_b:
        count += 1

print(count)

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

fr = max(A, C)
to = min(B, D)

if to - fr > 0 :
    print(to-fr)
else :
    print(0)

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

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

Solution (Python):
x=[int(_) for _ in input().split()]
if x[1]<=x[2] or x[3]<=x[0]:
    print(0)
else:
    print(min([x[1],x[3]])-max([x[0],x[2]]))

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

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):
a, b, c, d = map(int, input().split())
ans = min(b, d)-max(a, c)
if ans < 0:
    print(0)
else:
    print(ans)

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

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

if ans <0:
  print(0)
else :
  print(ans)

Solution (Python):

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




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

Solution (Python):
a,s,d,f=map(int,input().split())
l=sorted([a,s,d,f])
print(0) if (l[1]==s and l[2]==d) or (l[1]==f and l[2]==a) else print(l[2]-l[1])

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

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

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

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

if x<0:
 print(0)
else:
 print(x)

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

list_A_B =range(A,B)
list_C_D =range(C,D)

list_judge =[]




for i in list_A_B:
    for j in list_C_D:
        if i == j:
            list_judge.append(i)
        else:
            pass

print(len(list_judge))

Solution (Python):
if __name__ == '__main__':
    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(d,b)-max(a,c)
if time<0:
    print("0")
else:
    print(time)

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

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

if b <= c or d <= a:
    print(0)
elif a >= c and b <= d:
    print(b - a)
elif a <= c and b >= d:
    print(d - c)
elif a >= c and b >= d:
    print(d - a)
elif a <= c and b <= d:
    print(b - 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)>0 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 = list(map(int,input().split(' ')))



a = set(range(A,B+1))
b = set(range(C,D+1))
x = list(a & b)
if x:
  print(x[-1]-x[0])
else:
  print(0)

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

Solution (Python):
if __name__ == '__main__':
    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())
if b<=c or d <= a :
    print(0)
elif c<=b:
    if c <= a and b<=d:
        print(b-a)
    elif a<= c and b<=d:
        print(b-c)
    elif a<=c and d<=b:
        print(d-c)
    elif c<=a and d<=b:
        print(d-a)

Solution (Python):
a,b,c,d = map(int,input().split())
t = False
if(a<=c<=b or a<=d<=b or c<=a<=d or c<=b<=d):
    t = True
else:
    t = False

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

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

def calc():
    if a <= c:
        if b < c:
            return 0
        if b >= d:
            return (d - c)
        return b - c
    else:
        if d < a:
            return 0
        if d >= b:
            return b - a
        return d - a

print(calc())

Solution (Python):
a,b,c,d = map(int,input().split())
Alice = list(range(a,b+1))
Bob = list(range(c,d+1))
p =list(set(Alice) & set(Bob))
if p==[]:
    print(0)
else:
    print(p[-1]-p[0])

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

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())
dic = {}
count = -1

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

for j in range(c, d+1):
    if j in dic:
        count += 1
if count == -1:
    count = 0
print(count)

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

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

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

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

Alice = range(A, B+1)
Bob = range(C, D+1)
A_B = len(list(set(Alice) & set(Bob))) - 1
if(A_B >= 0):
    print(A_B)
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 = [int(i) for i in input().split()]

start = max([a,c])
end = min([b,d])

ans = end - start

if ans>0:
  print(ans)
else:
  print(0)

Solution (Python):
a, b, c, d = map(int, input().split())
e = max(a, c)
f = min(b, d)
print(f - e if f - e >= 0 else 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())
alice = [int(x) for x in range(a,b)]
bob = [int(y) for y in range(c,d)]
s = set()
for i in alice:
	s.add(i)
for j in bob:
	s.add(j)
print((len(alice)+len(bob))-len(s))

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

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

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

Solution (Python):

import sys
INF = float("inf")


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

    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())
print(max(0,min(b,d)-max(a,c)))

Solution (Python):
a = list(map(int,input().split()))
if a[2] < a[1] and a[0] < a[3]:
  a = sorted(a)
  print(a[-2] - a[1])
elif a[2] >= a[1] or a[0] >= a[3]:
  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())
list=[]

for i in range(101):
  list.append(0)
for i in range(a,b+1):
  list[i]=1
for i in range(c,d+1):
  list[i]+=1

ans = 0
for i in range(101):
  if list[i] == 2:
    ans +=1

if ans ==0:
  print(ans)
else:
  print(ans-1)

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

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