#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long ans = 0, tmp = 0;
  for (long long i = 0; i < n; i++) {
    tmp++;
    if (tmp >= a[i]) {
      tmp = 0;
      ans++;
    }
  }
  cout << ans << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = 0;
  for (long long l = a; l <= b; l++) {
    if (l + c - 1 > d) {
      long long cnt = min(l + c - 1 - d, c - b + 1);
      ans += cnt * (d - c + 1);
      if (cnt == c - b + 1) continue;
      long long res = ((d + 1 - l) + l - 1) - c + 1;
      long long res2 = max(0ll, (b + l - 1) - c + 1);
      ans -= (res2 * (res2 - 1)) / 2 - (res * (res + 1)) / 2;
    } else {
      long long res = (c + l - 1) - c + 1;
      long long res2 = max(0ll, (b + l - 1) - c + 1);
      ans -= (res2 * (res2 - 1)) / 2 - (res * (res + 1)) / 2;
    }
  }
  cout << ans;
}
