#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define int long long int #define rep(i, n) for(int i = 0; i < (n); ++i) #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) #define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) using namespace std; typedef pair P; const int INF = 1e15; const int MOD = 1e9+7; template using vector2 = vector>; template vector2 initVec2(size_t n0, size_t n1, T e = T()){ return vector2(n0, vector(n1, e)); } template using vector3 = vector>>; template vector3 initVec3(size_t n0, size_t n1, size_t n2, T e = T()){ return vector3(n0, vector2(n1, vector(n2, e))); } signed main(){ ios::sync_with_stdio(false); cin.tie(0); int a, b, c, d; cin >> a >> b >> c >> d; int ans = 0; for(int i = a; i <= b; i++){ ans += d - c + 1; if(c <= i && i <= d){ ans--; } } cout << ans << endl; return 0; }