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



Sample input:
0 75 25 100


Sample output:
50

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = -1
for i in range(100):
  if(A <= i <= B and C <= i <= D):
    cnt += 1
if(cnt == -1):
  print(0)
else:
  print(cnt)

Submission status: Wrong Answer

Solution code:
a,b,c,d=[int(i) for i in input().split()]
e = max(a,b)
f = min(c,d)
print(f-e)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    a, b, c, d = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    a, b, c, d = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    a, b, c, d = map(int, input().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
A=a[0]
B=a[1]
C=a[2]
D=a[3]
yeah=[0,]*101
ans=0
for i in range(A,B+1):
    yeah[i]+=1
for i in range(C,D+1):
    yeah[i]+=1
for i in range(100):
    if yeah[i]==2:
        ans+=1
if ans>0:
    ans-=1
print(str(ans))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
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)

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int, input().split())
a_b = [i for i in range(a, b+1)]
c_d = [i for i in range(c, d+1)]
counter = -1
flg = "False"

for i in range(len(a_b)):
  for j in range(len(c_d)):
    if a_b[i] == c_d[j]:
      counter += 1
      flg = "True"

if flg:
  print(counter)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int, input().split())
a_b = [i for i in range(a, b+1)]
c_d = [i for i in range(c, d+1)]
counter = 0

for i in range(len(a_b)):
  for j in range(len(c_d)):
    if a_b[i] == c_d[j]:
      counter += 1

print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
inputList = list(map(int, input().split(' ')))
A = inputList[0]
B = inputList[1]
C = inputList[2]
D = inputList[3]
answer = 0
if C <= A <= D:
    answer = (D-A)
elif C <= A and B <= D:
    answer = (B-A)
elif A <= C and D <= B:
    answer = (D-C)
elif A <= C <= B <= D:
    answer = (B-C)
print(answer)

Submission status: Wrong Answer

Solution code:
T = [int(i) for i in input().split()]
if T[0] >= T[3] or T[2] >= T[1]:
  print(0)
elif T[0] >= T[2]:
  print(T[1] - T[2])
elif T[2] >= T[0]:
  print(T[3] - T[0])

Submission status: Wrong Answer

Solution code:
import sys

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

if b>c and d>b:
    print(b-c)
    sys.exit(0)

elif b<c:
    print(0)
    sys.exit(0)

elif b>c and d<b:
    print(b-c-abs(b-d))

Submission status: Wrong Answer

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

    if c < a < b < d:
        return b - a

    if a < c < d < b:
        return d - c

    if a < c < b < d:
        return b - c

    if c < a < d < b:
        return d - a

    if b < c or d < a:
        return 0


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

Submission status: Wrong Answer

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

    if c < b or c < d < a < b:
        return 0

    if c < a < b < d:
        return b - a

    if a < c < b < d:
        return b - c

    if a < c < d < b:
        return d - c


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

Submission status: Wrong Answer

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

    if c < b or d < a:
        return 0

    if c < a < b < d:
        return b - a

    if a < c < b < d:
        return b - c

    if a < c < d < b:
        return d - c


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

Submission status: Wrong Answer

Solution code:
def abc070_b():
    a, b, c, d = map(int, input().split())
    
    if c > b:
        return 0
    
    if c < a < b < d:
        return b - a
    
    if a < c < b < d:
        return b - c
    
    if a < c < d < b:
        return d - c
    
    
if __name__ == '__main__':
    print(abc070_b())

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
a,b,c,d = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
a,b,c,d = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
a,b,c,d = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
a,b,c,d = map(int, input().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
listA = list(map(int, input().split()))
if listA[1] < listA[2]:
    print(0)
else:
    listA.sort()
    print(listA[2]-listA[1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if A < C < B < D:
    print(B-C)
if A < C < D < B:
    print(D-C)
if C < A < D < B:
    print(D-A)
if C < A < B < D:
    print(B-A)

Submission status: Wrong Answer

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

if C < B:
    print(abs(C-A)+abs(D-B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L = list(map(int,input().split()))
if L[0] < L[2] and L[1] < L[3] :
    print(max(0,L[1]-L[2]))
elif L[0] > L[2] and L[1] > L[3] :
    print(max(0,L[1]-L[2]))
else :
    print(min(L[1]-L[0],L[3]-L[2]))

Submission status: Wrong Answer

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

def func1(k,l):
    if k>l:
        return l
    else:
        return k

def func(x):
    if (x[2]>x[1]) or (x[0]>x[3]):
        print("Check")
        return 0
    else:
        if x[0]>x[2]:
            return (func1(x[1],x[3])-x[0])
        else:
            return (func1(x[1],x[3])-x[2])

print(func(n))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input().split())
imos = [0 for i in range(101)]
imos[A] += 1
imos[B] -= 1
imos[C] += 1
imos[D] -= 1
for i in range(1, 101):
    imos[i] += imos[i - 1]
cnt = 0
for i in range(1, 101):
    if imos[i] == 2:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flag=0
if (b<=c)|(a>=d):
  t=0
  flag=1
if (a<=c)and(b>=d)and(flag==0):
  t=d-c
  flag=2
if (a>=c)and(b<=d)and(flag==0):
  t=b-a
  flag=3
if flag==0:
  t=abs(b-c)
print(t)

Submission status: Wrong Answer

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

flag=0
if (b<c)|(a>d):
  t=0
  flag=1
if (a<=c)and(b>=d)and(flag==0):
  t=d-c
  flag=2
if (a>=c)and(b<=d)and(flag==0):
  t=b-a
  flag=3
if flag==0:
  t=abs(b-c)
print(t)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

elif C > B:
    print(time)
elif A <= D and C <= A:
    time = abs(D-A)
    print(time)
elif A <=D and C > A:
    time = D-C
    print(time)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# vim: set fileencoding=utf-8 :
a1, a2, b1, b2 = map(int, raw_input().split())

# Aが動いてる間に
if a1 < b1 < a2:
    # Bが先に終わる
    if b2 < a2:
        print(b2 - b1)
    else:
        print(a2 - b1)
elif b1 < a1 < b2:
    # Bが先に終わる
    if a2 < b2:
        print(a2 - a1)
    else:
        print(b2 - a1)
else:
    print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(max(0, b-c))

Submission status: Wrong Answer

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

print(max(0, c-b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

if b < c or d < a:
  print(0)
  sys.exit()
elif b == c:
  print(d - a)
  sys.exit()
elif d == a:
  print(b - c)
  sys.exit()



if a < c:
  if b < d:
    print(b - c)
    sys.exit()
  else:
    print(d - c)
    sys.exit()
else:
  if b < d:
    print(b - a)
    sys.exit()
  else:
    print(d - a)
    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

if b + 1 < c or d + 1 < a:
  print(0)
  sys.exit()
elif b == c:
  print(d - a)
  sys.exit()
elif d == a:
  print(b - c)
  sys.exit()



if a < c:
  if b < d:
    print(b - c)
    sys.exit()
  else:
    print(d - c)
    sys.exit()
else:
  if b < d:
    print(b - a)
    sys.exit()
  else:
    print(d - a)
    sys.exit()

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,raw_input().split())
print sum([1 if A<=x<=B and C<=x<=D else 0 for x in range(101)])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def mi(x,y):
    if (x - y) > (y - x):
        return x - y
    else:
        return y - x

def ma(x,y):
    if (x - y) > (y - x):
        return y - x
    else:
        return x - y


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

print(ma(b,d) - mi(a,c))

Submission status: Wrong Answer

Solution code:
def mi(x,y):
    if (x - y) > (y - x):
        return x - y
    else:
        return y - x

def ma(x,y):
    if (x - y) > (y - x):
        return y - x
    else:
        return x - y


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

print(mi(b,d) - ma(a,c))

Submission status: Wrong Answer

Solution code:
def ko(x,y):
    if (x - y) > (y - x):
        return x - y
    else:
        return y - x

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

print(ko(b,d) - ko(a,c))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d = map( int, input().split() )
if a > d:
    print(0)
    exit()
r1 = max(0, b - c)
r2 = max(0, b - d)
print(max(0,r1 - r2))

Submission status: Wrong Answer

Solution code:
a,b,c,d = map( int, input().split() )
r1 = max(0, b - c)
r2 = max(0, b - d)
print(max(0,r1 - r2))

Submission status: Wrong Answer

Solution code:
import numpy
import re
import math

def main():
	"""
	テストコード実行
	:return:
	"""
	a, b, c, d = map(int, input().split())
	if b > c:
		print(abs(sorted([a, b, c, d])[1] - sorted([a, b, c, d])[2]))
	else:
		print("0")

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def dup(A, B):
    r = 0
    for x in A:
        print(x)
        if x in B:
          r = r + 1
    return r


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

A = range(a, b+1)
B = range(c, d+1)

result = dup(A, B) if len(A) <= len(B) else dup(B, A)

print(result)

Submission status: Wrong Answer

Solution code:
def smaller(x, y):
	if x < y: return x
	else: return y

def calc(a, b, c, d):
	if b < d: return 0
	else: return smaller(b, d) - c

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

if A > C:
	tmp1 = A
	tmp2 = B
	A = C
	B = D
	C = tmp1
	D = tmp2

print calc(A, B, C, D)

Submission status: Wrong Answer

Solution code:
def smaller(x, y):
	if x < y: return x
	else: return y

def calc(a, b, c, d):
	if b < d: return 0
	else: return c - smaller(b, d)

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

if A > C:
	tmp1 = A
	tmp2 = B
	A = C
	B = D
	C = tmp1
	D = tmp2

print calc(A, B, C, D)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

arr[a]=1
arr[b]=-1
arr[c]=1
arr[d]=-1
ans=0


for x in range(1,100):
    arr[x]+=arr[x-1]


for x in arr:
    if x==2:
        ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# ABC 070 B

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

Submission status: Wrong Answer

Solution code:
# ABC 070 B

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

def left(a, c):
    if a < c:
        return c
    return a

def right(b, d):
    if b < d:
        return b
    return d

right(B, D) - left(A, C)

Submission status: Wrong Answer

Solution code:
# ABC 070 B

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


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

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

Submission status: Wrong Answer

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

box = []
box.append(a)
box.append(b)
box.append(c)
box.append(d)


if c < abs(b-a):
	p = box[-2]
	q = box[-3]
	print(abs(q-p))
else:
	print(0)

Submission status: Wrong Answer

Solution code:
import sys

a,b,c,d = map(int,input().split(" "))
box = []
box.append(a)
box.append(b)
box.append(c)
box.append(d)


count = []
for i in range(a+1):
	for j in range(b+1):
 		for k in range(c+1):
 			for l in range(d+1):
 				if c < (b-a):
 					box.sort()
 					p = box[-2]
 					q = box[-3]
 					print(abs(q-p))
 					sys.exit()
 				else:
 					print(0)
 					sys.exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

before = 0
after = 0

if a >= b:
  before = a - b
else:
  before = b - a

if c >= d:
  after = d
else:
  after = c
print(after - before)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

start = a if a > c else c
end = b if b < d else d

ans = end - start

print(ans)

Submission status: Wrong Answer

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

ans = 0 if (b - c) < 0 else b - c

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
a,b,c,d=map(int, input().split())

if(b<=c):
    print("0")
    sys.exit()
if(a<=c):
    if(b<d):
        print(b-c)
    else:
        print(d-c)
else:
    if(d<b):
        print(d-a)
    else:
        print(b-a)

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
print(-a+b-c+d+2)

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
print(-a+b-c+d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

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

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

Submission status: Wrong Answer

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

s = max(A, C)
t = min(B, D)
d = t - s
if d < 0:
    d = 0 
print(t - s)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
line = input().rstrip().split()

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
line = input().rstrip().split()

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
line = input().rstrip().split()

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

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