#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, ans = 0;
const long long maxn = 1e6 + 5;
long long p[maxn];
int main() {
  cin >> a >> b >> c >> d;
  long long mx = min(b - a, c - b) + 1;
  for (long long i = a + b, t = 1; i <= b + c; ++i) {
    p[i] = t;
    t = min(t + 1, mx);
  }
  for (long long i = b + c - mx + 1, t = mx; i <= b + c; ++i) {
    p[i] = t;
    --t;
  }
  for (long long i = a + b; i <= b + c; ++i) {
    p[i] = p[i - 1] + p[i];
  }
  ans = p[b + c] * (d - c + 1);
  for (long long i = c; i <= d; ++i) {
    long long ind = min(b + c, i);
    ans -= p[ind];
  }
  cout << ans << endl;
}
