#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d, otv = 0, p, q, odin = 1;
  cin >> a >> b >> c >> d;
  for (long long x = a; x <= b; ++x) {
    if (d < x + b) {
      otv += (d - c + 1) * (c - b + 1);
      continue;
    }
    if (c <= x + b - 1) otv += (c - b + 1) * (x + b - c);
    p = max(odin, c + x - d);
    q = min(c - b, x);
    otv += (p + q) * (q - p + 1) / 2;
  }
  cout << otv;
}
