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