#!/usr/bin/env python3

# -*- coding: utf-8 -*-



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

#!/usr/bin/env python3

# -*- coding: utf-8 -*-







def main():

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



    if A <= D and B >= C:

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

    else:

        print((0))



if __name__ == "__main__": main()

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
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()

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():
    A, B, C, D = list(map(int, input().split()))
    if A <= D and B >= C:
        print((min(B, D) - max(A, C)))
    else:
        print((0))


if __name__ == "__main__":
    main()

-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) - - -    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) +    A, B, C, D = list(map(int, input().split())) +    if A <= D and B >= C: +        print((min(B, D) - max(A, C))) +    else: +        print((0))