#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  long long int r1, r2, r3, min, i, j, k, l, m, n, ans = 0;
  r1 = b - a + 1;
  r2 = c - b + 1;
  r3 = d - c + 1;
  if (r1 > r2) {
    min = r2;
    n = r1;
  } else {
    min = r1;
    n = r2;
  }
  m = b + c;
  l = a + b;
  r3 = l + min - 1;
  long long int count[m + 1], temp;
  count[m] = 0;
  j = 0;
  for (i = 0; i <= m; i++) count[i] = 0;
  for (i = m - 1; i >= c; i--) {
    if (j < min) {
      j++;
      temp = j;
    }
    count[i] = count[i + 1] + temp;
    if (i < r3 && temp > 0) temp--;
  }
  for (i = c; i <= d; i++) {
    if (i >= m) {
      break;
    } else {
      ans += count[i];
    }
  }
  if (ans > 0)
    cout << ans << endl;
  else
    cout << 1 << endl;
  return 0;
}
