#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d;
  long long ans = 0;
  cin >> a >> b >> c >> d;
  for (long long i = c; i <= d; ++i) {
    long long interval_a = (i - b) + 1, interval_b = (i - a) + 1;
    if (interval_b < b) {
      ans += (b - a + 1) * (c - b + 1);
    } else if (interval_b >= b && interval_b <= c) {
      interval_a = max(interval_a, b);
      long long y_extras = c - interval_b;
      long long inclusion = (interval_b - b) + 1 - (interval_a - b);
      long long x_range = b - a + 1;
      long long x_extras = x_range - inclusion;
      ans += (inclusion * x_extras) + ((inclusion * (inclusion + 1)) / 2) +
             (y_extras * x_range);
    } else {
      long long exclusion = interval_b - c;
      long long x_range = (b - a + 1) - exclusion;
      if (x_range <= 0) break;
      long long remo = 0;
      if (interval_a < b) remo = b - interval_a;
      ans += ((x_range * (x_range + 1)) / 2) - ((remo * (remo + 1)) / 2);
    }
  }
  cout << ans << endl;
  return 0;
}
