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

Solution (Python):


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

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

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

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 C >= B:
    print(0)
elif D <= A:
    print(0)
else:
    if 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())
count = 0
for i in range(101):
	if (A<=i<=B and C<=i<=D and A!=D and B!=C):
		count += 1
if (count>0):
	count -= 1
print(int(count))

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

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

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

alice_push_time = set(list(range(a, b + 1))) 
bob_push_time = set(list(range(c, d + 1)))

both_push_time = len(alice_push_time & bob_push_time)


if both_push_time > 0:
  both_push_time -= 1
print(both_push_time)

Solution (Python):
x = map(int, input().split())
x = sorted(zip(x, [1, -1, 1, -1]))
if x[1][1] == 1:
  print(x[2][0] - x[1][0])
else:
  print(0)

Solution (Python):
import numpy as np

A, B, C, D = map(int, input().split())
x = sorted(zip([A, B, C, D], [1, -1, 1, -1]))
if x[1][1] == 1:
  print(x[2][0] - x[1][0])
else:
  print(0)

Solution (Python):
import numpy as np

A, B, C, D = map(int, input().split())
x, y = zip(*sorted(zip([A, B, C, D], [1, -1, 1, -1])))
z = np.diff(x)[np.cumsum(y)[:-1] == 2]
print(z[0] if len(z) == 1 else 0)

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

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

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

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

Solution (Python):
A,B,C,D=map(int,input().split())
samelst=[]
for ali in range(A,B):
  for bob in range(C,D):
    if ali==bob:
      samelst.append(ali)
print(len(samelst))

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())
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)
else:
    print(d-a)

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

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

Solution (Python):


n,m,k,j = map(int, input().split())
print(max(0, min(m,j)-max(n,k)))

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

time = [0]*101
for i in range(a,b):
  time[i] += 1
for i in range(c,d):
  time[i] += 1
  
print(time.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 0)

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

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

Solution (Python):

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

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

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())
alice=[0]*(b-a+1)
bob=[0]*(d-c+1)
ct=0
for i in range (a,b+1):
    alice[ct]=i
    ct+=1
ct=0
for i in range (c,d+1):
    bob[ct]=i
    ct+=1
ans=len(set(alice)&set(bob))
if ans==0:
    print(ans)
else:
    print(ans-1)

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

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

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

print(ans)

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

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

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())
ans = 0
for i in range(101):
    if A<=i<B and C<=i<D:
        ans += 1

print(ans)

Solution (Python):
a, b, c, d = map(int, input().split())
ans = 0
if a <= c <= b <= d:
    ans = b-c
if c <= a <= d <= b:
    ans = d-a
if a <= c <= d <= b:
    ans = d-c
if c <= a <= b <= d:
    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):
data = list(map(int,input().split()))
if data[1] <= data[2] or data[3] <= data[0]:
	print(0)
else :
	s = sorted(data)
	print(s[2]-s[1])

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

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

if lower<=upper:
    print(upper-lower)
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())

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

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

length = 0

if b <= c or d <= a:
    length = 0
elif b <= d and c <= d and a <= c:
    length = b - c
elif d <= b and a <= d and c <= a:
    length = d -a
elif b <= d and c <= a:
    length = b - a
elif d <= b and a <= c:
    length = d - c

print (length)

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

alice = list(range(a, b+1))
bob = list(range(c, d+1))

ans = 0
for a in alice:
    if a in bob:
        ans += 1
if ans != 0:
    print(ans - 1)
else:
    print(0)

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

Solution (Python):


w=input().split(" ")
a=int(w[0])
b=int(w[1])
c=int(w[2])
d=int(w[3])
ans=0
for t in range(100):
    sum=0
    if t>=a and t<b:
        sum+=1
    if t>=c and t<d:
        sum+=1
    if sum==2:
        ans+=1
print(ans)

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

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

if A < C:
    if C < min(B, D):
        print(min(B, D) - C)
        exit()
elif C < A:
    if A < min(B, D):
        print(min(B, D) - A)
        exit()
else:
    print(min(B, D) - A)
    exit()

print(0)

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

Solution (Python):
a,b,c,d=[int(i) for i in input().split()]
if b<=c or d<=a:
    print(0)
elif a<=c and b<=d:
    print(b-c)
elif a>=c and b>=d:
    print(d-a)
elif a<=c and b>=d:
    print(d-c)
else:
    print(b-a)

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

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

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

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


x = set(a) &set(b)
if len(x) == 0 :
  print(0)
else :
  print(max(x)-min(x))

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

AB = [i for i in range(A, B+1)]
CD = [i for i in range(C, D+1)]

for sec in AB:
    if sec in CD:
        ans += 1

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

Solution (Python):

import math





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

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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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())
if b<=c or d<=a:
    print(0)
else:
    time=[]
    time.append(a)
    time.append(b)
    time.append(c)
    time.append(d)
    time.sort()
    print(time[2]-time[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())

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

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

Solution (Python):

import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)

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 min(B,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())

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

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

ans = end - start
if ans < 0:
    ans = 0

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

Solution (Python):




"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""








def main():
  a,b,c,d = map(int,input().split())
  if b >= c:
    if a <= d:
      l = max(a,c)
      r = min(b,d)
      print(abs(r-l))
      exit()
    else:
      print(0)
      exit()
  else:
    print(0)
    exit()
if __name__ == '__main__':
  main()

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

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

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

Solution (Python):
import sys

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

num_list = [a, b, c, d]
num_list.sort()

time = 0

if a >= d or b <= c:
    time = 0
else:
    time = num_list[-2] - num_list[1]

print("{}".format(time))

Solution (Python):
A, B, C, D = map(int, input().split())
im = max(A, C)
fm = min(B, D)
if fm - im >= 0:
    print(fm - im)
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())
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 a <= d and c <= b else 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(max(0, min(
  min(b-c, d-c),
  min(d-a, 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)
else:print(min(b-c,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())
if c<a and b<d:ans=b-a
elif d<a:ans=0
elif c<a:ans=d-a
elif d<b:ans=d-c
elif c<b:ans=b-c
else:ans=0
print(ans)

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 = ans + 1

if ans != 0:
    ans = ans - 1

print(ans)

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
a,b,c,d = iim()

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

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

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

Solution (Python):
A,B,C,D=list(map(int, input().split()))
ma=min(B,D)
mi=max(A,C)
c=ma-mi
if c<0:
  c=0
print(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 = (int(x) for x in input().split())
ans1 = max(0, min(b,d) - max(a,c))
print(ans1)

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

if res < 0:
    res = 0

print(res)

Solution (Python):
a, b, c, d = map(int, input().split())
t = min(b, d) - max(a, c)
if t > 0:
    print(t)
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())
ans = max(min(B,D)-max(A,C),0)
print(ans)

Solution (Python):












mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    a,b,c,d = map(int,input().split())
    ans = 0
    if a<=c:
        if b<=c: pass
        elif b>=d: ans = d - c
        else: ans = b - c
    else:
        if a>=d: pass
        elif b<=d: ans = b - a
        else: ans = d - a
    print(ans)
    return

if __name__=='__main__':
    main()

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

Solution (Python):

A,B,C,D = map(int,input().split())
L1 = [A,C]
L2 = [B,D]
L1.sort()
L2.sort()
x = L2[0]-L1[1]
if x <0:
    print(0)
elif x >=0:
    print(x)

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

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

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

if A<C:
  if B-C < 0:
    print(0)
  else:
    if D-B < 0:
      x = B-D
    else:
      x = 0
    print(B-C-x)
else:
  if D-A < 0:
    print(0)
  else:
    if B-D < 0:
      x = D-B
    else:
      x = 0
    print(D-A-x)

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())
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:
    start = a
else:
    start = c

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

simultaneously = end - start

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

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

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

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

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

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

list=[0]*101

for i in range(A[0],A[1]+1):
  list[i]+=1

for i in range(A[2],A[3]+1):
  list[i]+=1
if list.count(2)>=1:
  print(list.count(2)-1)
else:
  print(0)

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

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

Solution (Python):
A,B,C,D = map(int,input().split())
count = 0
for i in range(A,B):
  for j in range(C,D):
    if i == j:
      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(' '))
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(0 if a>=d or b<=c else min(b,d)-max(a,c))

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

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

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

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

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

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

if a > c:
    a, b, c, d = c, d, a, b

if c < b:
    print(min(b, d) - 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())
l=[a,b,c,d]
l.sort()
if l[1]==b and l[2]==c:
    print(0)
elif l[1]==d and l[2]==a:
    print(0)
else:
    print(l[2]-l[1])

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

if a > c:
    a, c = c, a
    b, d = d, b

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

print(ans)

Solution (Python):
A,B,C,D = map(int, input().rstrip().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())
As = [i for i in range(a, (b + 1))]
Bs = [i for i in range(c, (d + 1))]

ans = []
for A in As:
    for B in Bs:
        if A == B:
            ans.append(A)
if ans:
    print(ans[-1] - ans[0])
else:
    print(0)

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

Solution (Python):

import sys


def solve(A: int, B: int, C: int, D: int):
    print(len(set(range(A, B)) & set(range(C, D))))


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 = list(map(int,input().split()))
m1 = min(a,b)
m2 = min(c,d) 
m3 = max(a,b)
m4 = max(c,d) 

x = m1 if m1 > m2 else m2
y = m3 if m3 < m4 else m4
print(y-x if y-x > 0 else 0)

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

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

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

if a < c:
    st = c
else:
    st = a

if b < d:
    ed = b
else:
    ed = d

if st < ed:
    print(ed-st)
else:
    print(0)

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())
ab = [ 1 if a<= i and i < b else 0 for i in range(100)]
cd = [ 1 if c<= i and i < d else 0 for i in range(100)]
cnt = 0

for i in range(100):
    if ab[i] == 1 and cd[i] == 1:
        cnt += 1

print(cnt)

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 = [int(i) for i in input().split()]

if A < C:
    start_time = C
else :
    start_time = A

if B > D:
    stop_time = D
else :
    stop_time = B
    

if stop_time-start_time <= 0:
    print(0)
else :
    print(stop_time-start_time)

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

l, r = max(a, c), min(b, d)

print(max(0, r - l))

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

Solution (Python):








def resolve():

    A,B,C,D=map(int,input().split())
    val=len(set(range(A,B+1)) & set(range(C,D+1)))
    print(val-1 if val>0 else 0)

resolve()

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

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

Solution (Python):
a,b,c,d = [int(i) for i in input().split()]
if c >= b or d <= a:
  print(0)
else:
  if a <= c and b >= d:
    print(d-c)
  elif c < a and b < d:
    print(b-a)
  elif a <= c < b <= d:
    print(b-c)
  else:
    print(d-a)

Solution (Python):

s = input().split()
t = [int(p) for p in s]


'''

count = 0
for i in range(1, max(t)+1):
    if(t[0] < i and i <= t[1] and t[2] < i and i <= t[3]):
        count += 1
print(count)
'''

start = max(t[0], t[2])
goal = min(t[1], t[3])
time = max(0, goal - start)


print(time)

Solution (Python):

s = input().split()
t = [int(p) for p in s]



count = 0
for i in range(1, max(t)+1):
    if(t[0] < i and i <= t[1] and t[2] < i and i <= t[3]):
        count += 1
print(count)

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

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

Solution (Python):
fromA, toA, fromB, toB = map(int, input().split())

if fromA >= fromB:
  st = fromA
else:
  st = fromB
  
if toA <= toB:
  ed = toA
else:
  ed = toB

ret = ed - st
if ret < 0:
  ret = 0

print(ret)

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

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

Solution (Python):
a=list(map(int, input().split()))
x=0

for i in range(101):
	if a[0]<=i and a[1]>=i and a[2]<=i and a[3]>=i:
		x=x+1
if x==0:
	print(0)
else:
	print(x-1)

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

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):
import sys
input = sys.stdin.readline

A, B, C, D = map(int, input().split(' '))
min_bd = min(B, D)
max_ac = max(A, C)
diff = min_bd - max_ac
ans = 0
if diff > 0:
    ans = abs(diff)
print(ans)

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())
start = max(A,C)
end = min(B,D)
print(max(0,end-start))

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):
import sys
input = sys.stdin.readline

A, B, C, D = map(int, input().split(' '))
a_switch = set()
b_switch = set()
for i in range(A+1, B+1):
    a_switch.add(i)
for i in range(C+1, D+1):
    b_switch.add(i)
ans = len(a_switch & b_switch)
print(ans)