# encoding:utf-8

import copy

import random

import bisect #bisect_left　これで二部探索の大小検索が行える

import math



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



cnt = 0

for i in range(101):

    if A<i<=B and C< i <= D:

        cnt += 1



print(cnt)

#!/usr/bin/env python3

# encoding:utf-8

import copy

import random

import bisect #bisect_left　これで二部探索の大小検索が行える

import fractions #最小公倍数などはこっち

import math

import sys

import collections

from decimal import Decimal # 10進数で考慮できる



mod = 10**9+7

sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000



d = collections.deque()

def LI(): return list(map(int, sys.stdin.readline().split()))



A, B, C, D = LI()

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

print(ans)
# encoding:utf-8
import copy
import random
import bisect  # bisect_left　これで二部探索の大小検索が行える
import math

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

#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect  # bisect_left　これで二部探索の大小検索が行える
import fractions  # 最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal  # 10進数で考慮できる

mod = 10**9 + 7
sys.setrecursionlimit(mod)  # 再帰回数上限はでdefault1000
d = collections.deque()


def LI():
    return list(map(int, sys.stdin.readline().split()))


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

+#!/usr/bin/env python3 +import fractions  # 最小公倍数などはこっち +import sys +import collections +from decimal import Decimal  # 10進数で考慮できる -A, B, C, D = list(map(int, input().split())) -cnt = 0 -for i in range(101): -    if A < i <= B and C < i <= D: -        cnt += 1 -print(cnt) +mod = 10**9 + 7 +sys.setrecursionlimit(mod)  # 再帰回数上限はでdefault1000 +d = collections.deque() + + +def LI(): +    return list(map(int, sys.stdin.readline().split())) + + +A, B, C, D = LI() +ans = max(min(B, D) - max(A, C), 0) +print(ans)