#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, d, arr[500005], sz;
  cin >> a >> b >> c >> d;
  for (long long int i = 0; i <= c - b; i++) {
    arr[i] = i + b;
  }
  sz = c - b + 1;
  long long int ans = 0;
  for (long long int i = a; i <= b; i++) {
    long long int ind = upper_bound(arr, arr + sz, c - i) - arr;
    if (ind < sz) {
      long long int x = sz - ind;
      long long int covered = min(d - c + 1, arr[ind] + i - c - 1);
      ans += covered * x;
      long long int n = min(d - c + 1 - covered, x);
      ans += n * (2 * x - n + 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
