#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int crt = 0;
  long long cnt = 0;
  bool f = 0;
  for (int xy = a + b; xy <= b + c; xy++) {
    if (!f && crt <= min(b - a, c - b)) {
      crt++;
    } else if (b + c - xy + 2 <= crt) {
      f = 1;
      crt--;
    } else {
      crt = crt;
    }
    if (xy <= c) {
      continue;
    }
    cnt += 1LL * crt * (min(d + 1, xy) - c);
  }
  cout << cnt;
  return 0;
}
