#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7, N = 1e6 + 10;
ll upd[N];
ll fin_upd[N];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll ans = 0;
  auto update = [&](ll x, ll y, ll v) {
    x = max(0ll, x);
    y = min(N - 2, y);
    upd[x] += v;
    upd[y + 1] += (-v);
  };
  for (ll i = A; i < B + 1; i++) {
    ll mnz = B - i + 1;
    ll mxz = B + i - 1;
    update(mnz, mnz + C - B, 1);
    update(mxz + 1, mxz + C - B + 1, -1);
  }
  ll cur = 0;
  for (ll i = 0; i < N; i++) {
    cur += upd[i];
    fin_upd[i] = cur;
  }
  cur = 0;
  for (ll i = 0; i < N; i++) {
    cur += fin_upd[i];
    if (i >= C and i <= D) {
      ans += cur;
    }
  }
  cout << ans << '\n';
  return 0;
}
