#include //#define int long long #define FOR(i, a, b) for (int i = a; i < b; ++i) #define rep(N) for (int i = 0; i < N; ++i) #define Rep(a, b) for (int i = a; i < b; ++i) #define For(i, N) for (int i = 0; i < N; ++i) #define all(v) v.begin(), v.end() #define rev(v) v.rbegin(), v.rend() #define mi(N) int N; cin >> N; #define ms(s) string s; cin >> s; #define md(d) double d; cin >> d; #define mv(v, N) vi v(N); rep(N)cin >> v[i]; #define mod 1000000007 using namespace std; using ll = long long; using vi = vector; using vvi = vector>; using vll = vector; using vb = vector; using vvb = vector>; using vs = vector; using pii = pair; using pis = pair; using msi = map; template void say(T s) { cout << s << "\n"; } template void say(vector s) { auto itr = s.begin(); cout << *(itr++); while (itr != s.end()) { cout << " " << *(itr++); } cout << "\n"; } template void say(vector s, char r) { auto itr = s.begin(); cout << *(itr++); while (itr != s.end()) { cout << r << *(itr++); } cout << "\n"; } void yn(bool b) { if (b)say("yes"); else say("no"); } void Yn(bool b) { if (b)say("Yes"); else say("No"); } void YN(bool b) { if (b)say("YES"); else say("NO"); } void Yay(bool b) { if (b)say("Yay!"); else say(":("); } template void maxi(T& a, T b) { a = max(a, b); } template void mini(T& a, T b) { a = min(a, b); } void exact_say(double x) { cout << setprecision(numeric_limits::max_digits10) << x << endl; } template vector> fill_vector(int h, int w, T val) { vector> ret; vector v(w, val); rep(h)ret.push_back(v); return ret; } template T max(vector v) { T ret = v[0]; Rep(1, v.size())maxi(ret, v[i]); return ret; } template T min(vector v) { T ret = v[0]; Rep(1, v.size())mini(ret, v[i]); return ret; } signed main() { mi(a); mi(b); mi(c); mi(d); ll ans = 0; Rep(a, b + 1) { if (c <= i && i <= d)ans += d - c; else ans += d - c + 1; } }