#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, cnt, m, n, a, b, c, d, i, j, x, z, sum = 0;
  cin >> a >> b >> c >> d;
  for (i = max(a + b, c); i <= c + d; i++) {
    m = min(i - c, d - c + 1);
    n = i - a - b + 1 - max(0ll, i - b - b) - max(0ll, i - a - c) +
        max(0ll, i - b - c - 1);
    sum += m * n;
  }
  cout << sum << endl;
}
