A, B, C, D = map(int, input().split()) ab = (B - A + 1) cd = (D - C + 1) ans = ab*cd if A == B and B == C and C == D: ans = 0 elif A <= C and B >= C and B <= D: ans -= (B - C + 1) elif A >= C and A <= D and B >= D: ans -= (D - A + 1) elif A < C and B > D: ans -= cd elif A > C and B < D: ans -= ab print(ans)