#include <bits/stdc++.h>
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    uint64_t ans = 0;
    for(int x=a;x<=b;x++){
        if(c<=x && x<=d) ans += d-c;
        else ans += d-c+1;
    }

    cout << ans << endl;
    
    return 0;
}