#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
const long long INF = 1e9 + 7;
const long long maxn = 2e5 + 7;
using namespace std;
void solve() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = 0;
  for (long long z = c; z < d + 1; z++) {
    long long r1 = z - c + 1;
    long long r2 = z - b + 1;
    if (r1 > b) continue;
    long long sStart = 1;
    if (r2 < b) {
      sStart += (b - r2);
    }
    r2 = max(r2, b);
    long long numTerms = c - r2 + 1;
    long long whichTermGreater = b - a + 2 - sStart;
    long long numGreater = max(min(numTerms - whichTermGreater, numTerms), 0LL);
    ans += numGreater * (b - a + 1);
    numTerms -= numGreater;
    long long finalTerm = sStart + numTerms - 1;
    long long summn = (numTerms) * (sStart + finalTerm);
    summn /= 2;
    ans += summn;
  }
  cout << ans << '\n';
}
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
