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

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    n = S()
    n1 = n[::-1]
    for i in range(len(n)):
        if n1[i] != n[i]:
            print("No")
            return
    print("Yes")
    return


def B():
    a, b, c, d = LI()
    ans = [0 for i in range(101)]
    ans[a] += 1
    ans[b] -= 1
    ans[c] += 1
    ans[d] -= 1
    for i in range(100):
        ans[i+1] += ans[i]
    print(ans.count(2))

def C():
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    B()

Solution (Python):
import math
def p(d): print(d)
def i(): return input()

def LI():  
    
    return int(input())
def LIS():  
    
    return [int(x) for x in input().split()]
def MLIS(n):  
    
    return [[int(x) for x in input().split()] for y in range(n)]
def LC():  
    
    return input()
def LCS(): 
    
    return [x for x in input().split()]
def MLCS(n): 
    
    return [[x for x in input().split()] for y in range(n)]

def alp2int(alphabet):
    
    return ord(alphabet) - ord('a')
def int2alp(num):
    
    return chr(num + ord('a'))
def cnt2dic(lst, dic={}):
    
    for x in lst:
        key = str(x)
        if key in dic:
            dic[key] += 1
        else:
            dic[key] = 1
    return dic
def dic2lst(dic, key=lambda x:x[1]):
    
    return sorted(list(dic.items()), key=key);

def A():
    a = LC()
    if a[0] == a[2]:
        print('Yes')
    else:
        print('No')

def B():
    a, b, c, d = LIS()
    s = max(a, c)
    e = min(b, d)
    if s < e:
        p(e-s)
    else:
        p(0)

def C():
    pass

def D():
    pass

def E():
    pass

def F():
    pass

def G():
    pass

def H():
    pass

B()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


"""
n = S()
if n == n[::-1]:
    print("Yes")
else:
    print("No")
"""

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

"""
def gcd(a,b):
    if a == 0:
        return b
    return gcd(b%a,a)
n = I()
a = IR(n)
l = a[0]
for i in range(1,n):
    g = gcd(l,a[i])
    l *= a[i]//g
print(l)
"""


"""
n = I()
v = [[] for i in range(n)]
for i in range(n-1):
    a,b,c = LI()
    a -= 1
    b -= 1
    v[a].append([b,c])
    v[b].append([a,c])
Q,k = LI()
d = [-1 for i in range(n)]
d[k-1] = 0
q = deque()
q.append(k-1)
while q:
    x = q.pop()
    for y,c in v[x]:
        if d[y] == -1:
            d[y] = d[x]+c
            q.append(y)
for i in range(Q):
    x,y = LI()
    x -= 1
    y -= 1
    print(d[x]+d[y])
"""

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

Solution (Python):
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

A,B,C,D = read_int()
Max = max(A,B,C,D)

Alice = [True if i >= A and i < B  else False for i in range(Max)]
Bob = [True if i >= C and i < D  else False for i in range(Max)]
Overlap = [True if Alice[i] and Bob[i] else False for i in range(Max)]

sec = 0
for o in Overlap:
    if o:
        sec += 1

print(sec)

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

def diff(x, y):
    time = x - y
    return time

if A < C:
    t = diff(B, C)
    if C > B:
        t = 0
    elif D < B:
        t = diff(D, C)
else:
    t = diff(D, A)
    if A > D:
        t = 0
    elif B < D:
        t = diff(B, A)

print(t)

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

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

Solution (Python):

A,B,C,D = map(int, input().split())
s = A if A>=C else C
f = B if B<=D else D
ans = f-s if f-s>0 else 0
print(ans)

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

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

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

time = end - start

if time < 0:
    time = 0

print(time)

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

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()))
B = sorted(A)
print(0 if (A[2]>A[1] or A[0]>A[3]) else B[2]-B[1])

Solution (Python):
A, B, C, D = [int(_) for _ in 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(abs(max(A,C)-min(B,D)))

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

Solution (Python):
a, b, c, d = map(int, input().split())
alice = [1 if a <= i < b else 0 for i in range(0, 101)]
bob = [1 if c <= i < d else 0 for i in range(0, 101)]
print(len(['' for i in range(0, 101) if alice[i] == bob[i] == 1]))

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

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

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


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):
def main():
    a,b,c,d = [int(_) for _ in input().split()]
    print(max(min(b,d)-max(a,c),0))
    
main()

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

Solution (Python):
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)

Solution (Python):
""" AtCoder """

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

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

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

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

Solution (Python):

import sys

def main():
	a, b, c, d = map(int, input().split(" "))
	
	if c >= b or a >= d:
		print(0)
		sys.exit()
		
	bb = min(b, d)
	aa = max(a, c)
	
	print(bb - aa)
	
if __name__ == "__main__":
	main()

Solution (Python):

import sys

def main():
	a, b, c, d = map(int, input().split(" "))
	
	if c >= b or a >= d:
		print(0)
		sys.exit()
	
	if a <= c and b >= d:
		print(d - c)
		sys.exit()
	
	if a >= c and b <= d:
		print(b - a)
		sys.exit()
		
	if a < c:
		print(b - c)
		sys.exit()
		
	if a > c:
		print(d - a)
		sys.exit()
		
	if d < b:
		print(d - c)
		sys.exit()
		
	if d > b:
		print(b - c)
		sys.exit()
	
if __name__ == "__main__":
	main()

Solution (Python):
from itertools import accumulate

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

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

l = [0]*101
l[A] += 1
l[B] -= 1
l[C] += 1
l[D] -= 1
l = list(accumulate(l))
print(l.count(2))

Solution (Python):
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)

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

if t[1] <= t[2] or t[3] <= t[0]:
    print(0)
else:
    t.remove(min(t))
    t.remove(max(t))
    print(abs(t[1]-t[0]))

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

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

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

Solution (Python):

a, b, c, d = map(int, input().split())
ans = 0
if a < d and b > c:
    n = sorted([a, b, c, d])
    ans = n[2] - n[1]
print(ans)

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())
print(min(b-c,b-a,d-c,d-a)) 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())
p = [[a,'A'],[b,'B'],[c,'C'],[d,'D']]
p.sort()

if (p[1][1] == 'B' and p[2][1] == 'C') or (p[1][1] == 'D' and p[2][1] == 'A'):
    print(0)
else:
    print(p[2][0] - p[1][0])

Solution (Python):
a, b, c, d = list(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())
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())
s = max(a, c)
b = min (b, d)

if s >= b:
  print(0)
else:
  print(b - 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 = [int(i) for i in input().split()]
def check(a, b, c, d):
  if b <= c or d<=a:
    return 0
  elif c<=a and a<=d and d<=b: 
    return d-a
  elif a<=c and d<=b:
    return d-c
  elif c<=a and b<=d:
    return b-a
  elif a<=c and c<= b and b<=d:
    return b-c
print(check(a,b,c,d))

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

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

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

def swap(s,pos):
    s[pos]-=1
    s[pos+1]+=1
    print(s)
    if pos == n-2: return s
    if s[pos+2] == 0: swap(s,pos+1)
    return s

pl = 'abcdefghijklmnopqrstuvwxyz'




a,b,c,d= (int(i) for i in input().split())  








e = set([i for i in range(a,b)])
f = set([i for i in range(c,d)])
print(len(e & f))

Solution (Python):
times = [int(x) for x in input().split()]

print(max(0, min(times[1], times[3]) - max(times[0], times[2])))

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

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

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

print(len([i for i in range(A, B) if C <= i and i < D]))

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

print(ans)

Solution (Python):

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

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

"""
もし B < Dなら、 C - B
もし B > Dなら、 D - B

A < x < B
と
C < x < D
の共通範囲

"""

A_B_time = []
C_D_time = []

for i in range(A,B):
    A_B_time.append(i)
for i in range(C,D):
    C_D_time.append(i)


def calc_common_range(time1, time2):
    common_range = []
    for i in time1:
        if i in time2:
            common_range.append(i)
    return common_range


print(len(calc_common_range(A_B_time, C_D_time)))

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

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

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

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

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

ans=0
if a<=c:
    ans+=b-c
    if d<=b:
        ans-=b-d
else:
    ans+=d-a
    if b<=d:
        ans-=d-b

if ans>=0:
    print(ans)
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());s=[b,d][b>d]-[a,c][a<c]
print(s if s>0 else 0)

Solution (Python):
A, B, C, D = map(int, input().split())
l = [0] * 102

l[A] += 1
l[B] -= 1
l[C] += 1
l[D] -= 1

for i in range(1, len(l)):
    l[i] += l[i - 1]

ans = 0

for i in range(0, len(l)):
    if l[i] == 2:
        ans += 1

print(ans)

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

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(len(set(range(A, B+1)) & set(range(C, D+1)))-1, 0))

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

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

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

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

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

Solution (Python):
A,B,C,D=map(int,input().split())
Alice={s for s in range(A,B+1)}
Bob={s for s in range(C,D+1)}

print(len(Alice & Bob)-1 if len(Alice & Bob)!=0 else 0)

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

sup = max(D,B)
inf = min(A,C)

if B-A + D-C <= sup - inf:
    print(0)
else:
    print(B-A+D-C - (sup - inf))

Solution (Python):
A,B,C,D = map(int,input().split(" "))
list = [0] * 101
for j in range(A,B):
    list[j] += 1
for j in range(C,D):
    list[j] += 1

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

Solution (Python):
a,b,c,d=map(int,input().split())
A=[0 for i in range(100)]
for i in range(a,b):
  A[i]+=1
for j in range(c,d):
  A[j]+=1
print(A.count(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())
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())
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())
s=min(b,d)-max(a,c)
print(s) if s>0 else print(0)

Solution (Python):


import sys


INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


a, b, c, d = LI()
s = [0] * 101
s[a] += 1
s[b] -= 1
s[c] += 1
s[d] -= 1
for i in range(100):
    s[i + 1] += s[i]

print(s.count(2))

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

x = []
for i in range(A, B, 1):
  x.append(i)
y = []
for j in range(C, D, 1):
  y.append(j)
  
z = x + y

z_duplicate = [k for k in set(z) if z.count(k) > 1]
print(len(z_duplicate))

Solution (Python):
int_a, int_b, int_c, int_d = map(int,input().split())

range_a = range(int_a, int_b)
range_b = range(int_c, int_d)

print(len(set(range_a).intersection(set(range_b))))

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 = a if a > c else c
e = d if b > d else b
print(e-s if e-s > 0 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())
print(max(0, len(set(range(a, b+1)) & set(range(c, d+1)))-1))

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

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

ans = end - start
print(max(0, ans))

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

maxi = min(b, d)
mini = max(a, c)

if maxi - mini <= 0:
    print("0")
else:
    print(maxi-mini)

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

if a > c:
    min = a
else:
    min = c

if b < d:
    max = b
else:
    max = d

if max - min <= 0:
    print("0")
    exit()
else:
    print(max-min)

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

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

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


if __name__ == '__main__':
    main()

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

s = max(a, c)
e = min(b, d)

ans = max(0, e - s)

print(ans)

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

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

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

alice = [False] * 101
bob = [False] * 101

for i in range(a,b):
    alice[i] = True

for i in range(c,d):
    bob[i] = True

ans = sum([x and y for x, y in zip(alice, bob)])
print(ans)

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

Solution (Python):
as1,ae,bs,be = map(int,input().split())
da = {as1:'AS',ae:'AE'}
db = {bs:'BS',be:'BE'}
order = [as1,ae,bs,be]
order.sort()
Alice = False
Bob = False
start = -1
end = -1
for t in order:
  if t in da and da[t] == 'AS':
    Alice = True
  if t in db and db[t] == 'BS':
    Bob = True
  if t in da and da[t] == 'AE':
    Alice = False
  if t in db and db[t] == 'BE':
    Bob = False
  if Alice and Bob:
    start = t
  if start != -1 and (not(Alice) or not(Bob)):
    end = t
    break

print(str(end-start))

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

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

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




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

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

ans=0
for i in range(100+1):
  if a<i and i<=b and c<i and 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(0, min(b, d) - max(a, c)))

Solution (Python):
import sys
from itertools import product

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    A, B, C, D = il()
    return max(min(B, D) - max(A, C), 0)


if __name__ == "__main__":
    print(solve())

Solution (Python):
a, b, c, d = map(int, input().split())
lists = [0]*101
for i in range(101):
  if a<=i and i<b and c<=i and i<d:
    lists[i] = 1
print(sum(lists))

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

Solution (Python):

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

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

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

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

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

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

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

alice = [True if A <= i < B else False for i in range(max(B, D))]
bob = [True if C <= i < D else False for i in range(max(B, D))]

print(list(zip(alice, bob)).count((True, True)))

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

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

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

Solution (Python):
times = list(map(int, input().split()))
count = 0
for i in range(min(times), max(times)+1):
    if times[0] <= i < times[1] and times[2] <= i < times[3]:
        count += 1
print(count)

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

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

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


abc070_b()

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

count=[0]*100
answer=0
for i in range(0,100):
    if (i>=a and i<b):
        count[i]+=1

    if (i>=c and i<d):
        count[i]+=1


for i in range(0,100):
    if count[i]==2:
        answer+=1


print(answer)

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

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

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

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

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

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

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

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

Solution (Python):


if __name__ == "__main__":
    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):
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 = [int(i) for i in input().split()]
if d <= a or c >= b:
    print(0)
elif c <= a <= d:
    print(min(b, d) - a)
elif a <= c <= b:
    print(min(b, d) - 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 = list(map(int,input().split()))

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

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

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

lo = max(A,C)
up = min(B,D)

print(max(0,up-lo))

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

R = min(B, D)
L = max(A, C)
Diff = R-L
if Diff > 0:
  print(Diff)
  exit(0)
print(0)

Solution (Python):
A, B, C, D = map(int, input().split(" "))
if A < C:
  one = [A, B]
  two = [C, D]
else:
  two = [A, B]
  one = [C, D]
if one[1] < two[0]:
  print(0)
  exit(0)
if one[1] >= two[1]:
  print(two[1] - two[0])
  exit(0)
if one[1] < two[1]:
  print(one[1] - two[0])
  exit(0)

Solution (Python):
import collections as cl

A,B,C,D = [int(i) for i in input().split()]
arr = [0]*100

for i in range(A,B) :
    arr[i] += 1

for i in range(C,D) :
    arr[i] += 1

c = cl.Counter(arr)
print(c[2])

Solution (Python):
a=list(map(int,input().split()))
A=a[0]
B=a[1]
C=a[2]
D=a[3]
yeah=max(A,C)
yipee=min(B,D)
if yeah >= yipee:
    print("0")
else:
    print(str(yipee-yeah))

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

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

result = max(e - s, 0)

print(result)

Solution (Python):
A,B,C,D = map(int,input().split())
counter = 0
for num1 in range(A,B):
    for num2 in range(C,D):
        if num1 == num2:
            counter += 1
print(counter)

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

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

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

if A >= D or B <= C:
    ans = 0
else:
    ans = min(B, D) - max(A, C)

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

Solution (Python):

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

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

Solution (Python):
a=input().strip().split(" ")
a=[int(i) for i in a]

b=[]
c=[]

b.append(a[0])
b.append(a[2])

c.append(a[1])
c.append(a[3])

b.sort()
c.sort()

Sum=c[0]-b[1]

if(Sum<=0):
    print("0")
else:
    print(Sum)

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