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())
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,B,C,D = C,D,A,B

if C >= B:
    print("0")
elif C < B and D > B:
    print(B - C)
else:
    print(D - C)

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

Solution (Python):
def create_set(a, b, out):
    for i in range(a, b):
        out.add(i)

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

alice = set()
bob = set()
create_set(a, b, alice)
create_set(c, d, bob)

total = alice & bob

time_total = 0
for i in total:
    time_total += 1

print(time_total)

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

f = set([i for i in range(A, B)])
g = set([i for i in range(C, D)])
print(len(list(f.intersection(g))))

Solution (Python):
a_s, a_f, b_s, b_f = [int(x) for x in input().rstrip().split()]
result = min(a_f, b_f) - max(a_s, b_s)
if result > 0:
	print(result)
else:
	print("0")

Solution (Python):
a,b,c,d = map(int,raw_input().split())
t = [0 for _ in xrange(101)]
t[a] += 1
t[b] -= 1
t[c] += 1
t[d] -= 1
for i in xrange(len(t)):
  if(i > 0): t[i] += t[i-1]
count = 0
for i in xrange(len(t)):
  if(t[i] == 2): count += 1
print count

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, raw_input().split())

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

Solution (Python):
def Q2(x):
    A, B, C, D = x[0], x[1], x[2], x[3]
    time_lower = max(A, C)
    time_upper = min(B, D)
    return max(0, time_upper - time_lower)

l = [int(i) for i in input().split()]
print(Q2(l))

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

Solution (Python):


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

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

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

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

k = [ i for i in range(0,101) if A <= i <= B and C <= i <= D]
if not k:
    print(0)
else:
    print(max(k) - min(k))

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

    print(0)

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


def solve(A, B, C, D):
    if A < C:
        if B < C:
            return 0
        elif A <= C and D <= B:
            return (D - C)
        else:
            return (B - C)
    else:
        if D < A:
            return 0
        elif C <= A and B <= D:
            return (B - A)
        else:
            return (D - A)

print(solve(A, B, C, D))

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

t=0
if(C<A):
 if(D<=A):
  t=0
 if(A<D<=B):
  t=D-A
 if(B<D):
  t=B-A

if(A<C):
 if(B<=C):
  t=0
 if(C<B<=D):
  t=B-C
 if(D<B):
  t=D-C

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

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




def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    a, b, c, d = read_int_list()
    res = abs(max(a, c) - min(b, d))
    if c >= b or a >= d:
        res = 0
    print(res)


main()

Solution (Python):
def solve():
    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
    print(ans.count(2))

if __name__=="__main__":
    solve()

Solution (Python):

A,B,C,D=(int(i) for i in input().split())
if A<C:
    A=C
if B>D:
    B=D
B-=A
if B<0:
  print(0)
else:
  print(B)

Solution (Python):


a, b, c, d = map(int, input().split())
alice_time = [x for x in range(a, b+1)]
bob_time = [x for x in range(c, d+1)]
pushed_time = set(alice_time) & set(bob_time)

if len(pushed_time) == 0:
  print(0)
else:
  print(len(pushed_time) - 1)

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

answer = 0
for i in xrange(101):
  if A <= i < B and C <= i < D:
    answer += 1

print answer

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

b()

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

Solution (Python):
num = input()
num_ABCD = num.split()
num_A = int(num_ABCD[0])
num_B = int(num_ABCD[1])
num_C = int(num_ABCD[2])
num_D = int(num_ABCD[3])
if num_B <= num_C or num_D <= num_A:
    print(0)
else:
    if num_A <= num_C and num_B <= num_D:
        print(num_B - num_C)
    elif num_A <= num_C and num_B >= num_D:
        print(num_D - num_C)
    elif num_A >= num_C and num_B <= num_D:
        print(num_B - num_A)
    elif num_A >= num_C and num_B >= num_D:
        print(num_D - num_A)

Solution (Python):
a, b, c, d = map(int, raw_input().split())
table = dict()
for i in range(101):
    table[i] = 0
for i in range(a, b + 1):
    table[i] += 1
for i in range(c, d + 1):
    table[i] += 1
result = 0
for i in table:
    if table[i] == 2:
        result += 1
print(result - 1 if result > 0 else '0')

Solution (Python):
import sys

N = sys.stdin.readline()

N = N.split()
N = map(int, N)

if N[2] > N[1] or N[0] > N[3]:
	print 0

else:
	least = max(N[0], N[2])
	most = min(N[1], N[3])
	
	print abs(most- least)

Solution (Python):
a = input().split()
ast = int(a[0])
aen = int(a[1])
bst = int(a[2])
ben = int(a[3])
if ast > ben or bst > aen:
    print("0")
elif ast < bst and aen < ben:
    print(aen - bst)
elif ast < bst and aen > ben:
    print(ben - bst)
elif bst < ast and ben < aen:
    print(ben - ast)
elif bst < ast and ben > aen:
    print(aen - ast)
elif ast == bst and aen < ben:
    print(aen - ast)
elif ast == bst and aen > ben:
    print(ben - ast)
elif ast < bst and aen == ben:
    print(ben - bst)
elif ast > bst and aen == ben:
    print(aen - ast)
elif ast == bst and aen == ben:
    print(aen - ast)
else:
    print("0")

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


if A < C:
  a = C
else:
  a = A

if B < D:
  b = B
else:
  b = D
  
if B <= C or D <= A:
  res = 0
else:
  res = (b-a)
  
print(res)

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(i) for i in input().split()]
if a<c:
  x1=a
  x2=c
  y1=b
  y2=d
else:
  x1=c
  x2=a
  y1=d
  y2=b
if y1<x2:
   c=0
elif x2<=y1<=y2:
   c=y1-x2
else:
   c=y2-x2
print(c)

Solution (Python):
if __name__ == '__main__':
    Num = list(map(int, input().split()))
    st = [Num[0], Num[2]]
    en = [Num[1], Num[3]]
    if min(en) - max(st) > 0:
        print(min(en) - max(st))
    else:
        print('0')

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


def calc(A, B, C, D):
    
    
    
    
    if C <= A <= B <= D:
        return B - A
    elif A <= C <= D <= B:
        return D - C
    elif C <= A <= D:
        return D - A
    elif C <= B <= D:
        return B - C
    else:
        return 0

if __name__ == '__main__':
    main()

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

m = [0 for i in range(101)]
n = [0 for i in range(101)]

i = a
while(True):
    m[i] = 1
    if(i == b):
        break
    i+=1
i = c
while(True):
    n[i] = 1
    if(i == d):
        break
    i+=1

ans = 0
for i in range(101):
    if(m[i] * n[i] == 1):
        ans+=1

if(ans!=0):
    ans-=1

print(ans)

Solution (Python):
nums = [int(x) for x in input().split()]
nums = [ [nums[0],nums[1]] ,
         [nums[2],nums[3]] ]
N = 100
imos = [0 for i in range(N+2)]

for num in nums:
    a,b = num[0],num[1]-1
    imos[a] += 1
    imos[b+1] -= 1
 
ans = []
j = 0
for i in imos:
    ans.append(j+i)
    j += i

print(ans.count(2))

Solution (Python):
a=list(map(int,input().split()))
n=min(a[1],a[3])-max(a[0],a[2])
print(n if n>0 else 0)

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

Solution (Python):
a=map(int, raw_input().split())


a_start=a[0]
a_end=a[1]
b_start=a[2]
b_end=a[3]

if a_start<=b_start:
	c_start=b_start
else:
	c_start=a_start



if a_end<b_end:
	c_end=a_end
else:
	c_end=b_end



if c_end-c_start<0:
	print 0
else:
	print c_end-c_start

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

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

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

    sw = [0] * 101
    sw[A] = 1
    sw[B] = -1
    sw[C] += 1
    sw[D] += -1
    for i in range(1, 101):
        sw[i] = sw[i-1] + sw[i]

    ans = sw.count(2)
    print(ans)

main()

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

Solution (Python):
def Q2(x):
    A, B, C, D = x[0], x[1], x[2], x[3]
    if B <= C or D <= A:
        return 0
    else:
        if A <= C:
            return min(B, D) - C
        else:
            return min(B, D) - A
          
l = [int(i) for i in input().split()]
print(Q2(l))

Solution (Python):
xa, ya, xb, yb = map(int, input().split())

if xa > xb:
    x = xa
else:
    x = xb
if ya > yb:
    y = yb
else:
    y = ya
ans = y - x
if ans <= 0:
    print(0)
else:
    print(ans)

Solution (Python):
sp=list(map(int,input().split()))
time=min(sp[1],sp[3])-max(sp[0],sp[2])
if time >= 0:
	print(time)
else:
	print(0)

Solution (Python):



abcd = raw_input()
abcd = abcd.split()
abcd = map(int,abcd)

if abcd[0] >= abcd[3]:
    print 0
elif abcd[2] >= abcd[1]:
    print 0
elif abcd[0] < abcd[2]:
    if abcd[1] < abcd[3]:
        print abcd[1] - abcd[2]
    else:
        print abcd[3] - abcd[2]
else:
    if abcd[1] > abcd[3]:
        print abcd[3] - abcd[0]
    else:
        print abcd[1] - abcd[0]

Solution (Python):
a = map(int, raw_input().strip().split())
b = max(a[0],a[2])
c = min(a[1],a[3])
if c > b:
	ans = c-b
else:
	ans = 0
print(ans)

Solution (Python):

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

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

Solution (Python):
l=list(map(int,input().strip().split(' ')))
a=l[0]
b=l[1]
c=l[2]
d=l[3]
l1=[x for x in range(a,b+1)]
l2=[x for x in range(c,d+1)]
l3=[]
ans=0
for i in l2:
    if i in l1:
        ans+=1
print(max(0,ans-1))

Solution (Python):
arr=[int(x) for x in input().split()]
if(arr[0]< arr[2]):
    if(arr[2]<=arr[1]<=arr[3]):
        print(arr[1]-arr[2])
    elif(arr[1]<arr[2]):
        print('0')
    else:
        print(arr[3]-arr[2])
else:
    if(arr[0]<=arr[3]<=arr[1] ):
        print(arr[3]-arr[0])
    elif(arr[3]<arr[0]):
        print('0')
    else:
        print(arr[1]-arr[0])

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

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

Solution (Python):
A, B, C, D = input().split(' ')
A = int(A)
B = int(B)
C = int(C)
D = int(D)
ab = set([ x for x in range(A, B)])
cd = set([ x for x in range(C, D)])

print(len(ab & cd))

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

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

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

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

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

Solution (Python):
s = raw_input()
abcd = map(int, s.split())
if abcd[0] > abcd[2]:
	begin = abcd[0]
else:
	begin = abcd[2]
if abcd[1] > abcd[3]:
	end = abcd[3]
else:
	end = abcd[1]

if (end - begin) >= 0:
	print(end - begin)
else:
	print(0)

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

if B <= C:
    print("0")
elif D <= A:
    print("0")
else:
    start = max([A, C])
    end = min([B, D])
    print(end - start)

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

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

print(max(0, ans - 1))

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

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

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

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

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

time = min(b[1],b[3]) - max(b[0],b[2])

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

Solution (Python):
A, B, C, D = map(int, input().split())
X = set(range(A, B))
Y = set(range(C, D))
print(len(X.intersection(Y)))

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

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

Solution (Python):

def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    A, B, C, D = ILI()
    return A, B, C, D


def solve(A, B, C, D):
    l_ans = [0] * 101
    for a in range(A, B + 1):
        l_ans[a] += 1
    for b in range(C, D + 1):
        l_ans[b] += 1

    ans = 0
    for a in l_ans:
        if a == 2:
            ans += 1

    if ans != 0:
        ans -= 1

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

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

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

sec=end-start

if sec<0:
  print 0
else:
  print sec

Solution (Python):



import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)



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

    alice = [A <= t < B for t in range(100)]
    bob   = [C <= t < D for t in range(100)]

    cnt = 0
    for t in range(100):
        if alice[t] and bob[t]:
            cnt += 1

    print(cnt)

if __name__ == "__main__": main()

Solution (Python):


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

    xs = [0] * 101
    xs[a] += 1
    xs[b] -= 1
    xs[c] += 1
    xs[d] -= 1

    cursum = 0
    t = 0
    for x in xs:
        cursum += x
        if cursum == 2:
            t += 1

    print(t)


if __name__ == "__main__":
    main()

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

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

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

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

print(ans)

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:
        count += 1
        
print(count)

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

start = max(a,c)
stop = min(b,d)
time = stop-start

if time<0:
    print("0")
else:
    print(time)

Solution (Python):
a = list(map(int,input().split()))
if a[2] < a[0]: a = [a[2], a[3], a[0],a[1]]

if a[2] < a[1]:
	if a[3] < a[1]:
		print(a[3]-a[2])
	else:
		print(a[1]-a[2])
else:
	print(0)

Solution (Python):

def spaceinput():
    return list(map(int,input().split(" ")))



x=spaceinput()

l=max(x[0],x[2])
r=min(x[1],x[3])
v=r-l
if v>0:
    print(v)
else:
    print(0)

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

st = max(A, C)
ed = min(B, D)

print(max(ed - st, 0))

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

ans = 0

if B < C:
    pass
elif D < A:
    pass
else:
    ans = min(B, D) - max(A, C)

print ans

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

if c>b  or a>d:
    print("0")
else:
    print(b+d-a-c-(max(a,b,c,d)-min(a,b,c,d)))

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


x = max(a,c)
y = min(b,d)

z = max(y-x,0)

print(z)

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 = [int(i) for i in input().split()]
overlap = min(A[1], A[3]) - max(A[0], A[2])
if overlap >= 0:
    print(str(overlap))
else:
    print("0")

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

Solution (Python):
def f():
    a,b,c,d=map(int,input().split(' '))
    arun=range(a,b)
    brun=range(c,d)
    s=0
    for i in range(0,100):
        if i in arun and i in brun:
            s=s+1
    print(s)
f()

Solution (Python):
A,B,C,D = list(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, raw_input().split())

s = 0
on_a = 0
on_b = 0
for i in range(101):
    if i == a:
        on_a = 1
    if i == b:
        on_a = 0
    if i == c:
        on_b = 1
    if i == d:
        on_b = 0

    if on_a and on_b:
        s += 1

print(s)

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

Solution (Python):

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

if __name__ == '__main__':
	main()

Solution (Python):
def f(a, b, c, d):
    if a <= c:
        if b <= c:
            return 0
        if b <= d:
            return b - c
        else:
            return d - c
    else:
        return f(c, d, a, b)

a, b, c, d = [int(x) for x in input().strip().split()]
print(f(a, b, c, d))

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

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


def main():
    a, b, c, d = (int(x) for x in input().split())
    print(compute(a, b, c, d))


if __name__ == '__main__':
    main()

Solution (Python):
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))
def plis(a): return " ".join(list(map(str, a)))

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

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

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

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

ans = 0
for i in range(101):
    if i in range(a,b) and i in range(c,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, raw_input().split())
print max(0, min(b, d) - max(a, c))

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

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, raw_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, raw_input().split())

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

duration = max(0, end-start)

print duration

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, raw_input().split())
A = [0 for i in xrange(150)]

for i in xrange(150):
    if a <= i < b:
        A[i] += 1
    if c <= i < d:
        A[i] += 1

print A.count(2)

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