# coding:utf-8 import sys # from collections import Counter, defaultdict INF = float('inf') MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II(): return int(sys.stdin.readline()) def SI(): return input() def main(): a, b, c, d = LI() res = 0 for x in range(a, b + 1): for y in range(c, d + 1): if x == y: continue res += 1 return res print(main())