a, b, c, d = map(int, input().split()) if a > c: a, c = c, a b, d = d, b ans = (b - a + 1) * (d - c + 1) if b < c: pass elif c <= b <= d: ans -= b - c + 1 else: ans -= d - c + 1 print(ans)