#include using namespace std; using namespace chrono; #if __has_include() #include using namespace atcoder; #endif int main() { int64_t a, b, c, d; cin >> a >> b >> c >> d; int64_t dup = max(0, min(b - c + 1, d - a + 1)); int64_t m = b - a + 1; int64_t n = d - c + 1; int64_t ans = (m - dup) * (n - dup) + (m - dup) * dup + dup * (n - dup) + dup * (dup - 1); cout << ans << endl; return 0; }