#include <bits/stdc++.h>
using namespace std;
long long sum(long long n) { return (n * (n + 1)) / 2; }
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ans = 0;
    long long sz = d - c + 1;
    for (long long i = b; i <= c; i++) {
      if (i + a > d)
        ans += (b - a + 1) * sz;
      else if (i + a == d) {
        ans += sz - 1;
        ans += (b - a) * sz;
      } else if (i + b > d && i + a <= c) {
        long long rem = i + b - d;
        ans += (rem * sz);
        ans += sum(sz - 1);
      } else if (i + b == d && i + a > c) {
        long long rem = i + a - c;
        ans += sum(sz - 1) - sum(rem - 1);
      } else if (i + b > d && i + a > c) {
        long long rems = i + a - c;
        long long remb = i + b - d;
        ans += (remb)*sz;
        ans += sum(sz - 1) - sum(rems - 1);
      } else if (i + a == c && i + b == d)
        ans += sum(sz - 1);
      else if (i + a == c && i + b < d) {
        long long rem = i + b - c;
        ans += sum(rem);
      } else if (i + a > c && i + b == d) {
        long long rem = i + a - c;
        ans += sum(sz - 1) - sum(rem - 1);
      } else if (i + a > c && i + b < d) {
        long long rem1 = i + a - c;
        long long rem2 = i + b - c;
        ans += sum(rem2) - sum(rem1 - 1);
      } else if (i + a < c && i + b > c) {
        long long rem = i + b - c;
        ans += (sum(rem));
      }
    }
    cout << ans << endl;
  }
}
