#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
long long fastPowMod(long long a, long long p, long long mod) {
  if (p == 0) return 1;
  long long z = fastPowMod(a, p / 2, mod);
  z = (z * z) % mod;
  if (p % 2) z = (z * a) % mod;
  return z;
}
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &x : v) is >> x;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];
  }
  return os;
}
void solve() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<long long> pref(b + c + 2, 0);
  for (long long x = a; x <= b; x++) {
    pref[x + b]++;
    pref[x + c + 1]--;
  }
  for (long long i = 0; i < pref.size() - 1; i++) pref[i + 1] += pref[i];
  for (long long i = pref.size() - 1 - 1; i >= 0; i--) pref[i] += pref[i + 1];
  long long ans = 0;
  for (long long z = c; z <= d; z++) {
    if (z >= (b + c)) break;
    ans += pref[z + 1];
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  cout << "\n";
  return 0;
}
