#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;
ll res;
void solve() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  for (int i = c; i <= d; ++i) {
    ll gg = (i - c);
    if (b <= gg) continue;
    gg = min(b - gg, b - a + 1);
    ll lo = b - 1, hi = c;
    while (lo + 1 < hi) {
      ll m = lo + hi >> 1LL;
      ll wp = i - m;
      if (b < wp)
        lo = m;
      else if (min(b - wp, b - a + 1) == gg)
        hi = m;
      else
        lo = m;
    }
    res += (c - hi + 1) * gg;
    ll rem = hi - b;
    ll cur = hi - 1;
    gg = (i - cur);
    if (b <= gg) continue;
    gg = min(b - gg, b - a + 1);
    if (gg <= rem)
      res += (gg * (gg + 1) / 2);
    else
      res += (gg * (gg + 1) / 2 - (gg - rem) * (gg - rem + 1) / 2);
  }
  cout << res << "\n";
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  while (t--) {
    solve();
  }
}
