#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int main() {
  long long a, b, c, d;
  long long ans = 0;
  cin >> a >> b >> c >> d;
  for (long long i = a; i <= b; i++) {
    long long mn = c - i + 1;
    if (mn > c) continue;
    if (mn < b) {
      long long fir = i + b;
      long long sec = i + c;
      if (fir >= d + 1) {
        ans += (c - b + 1) * (d - c + 1);
        continue;
      }
      if (sec > d + 1) {
        ans += (sec - d - 1) * (d - c + 1);
        sec = d + 1;
      }
      fir = fir - c;
      sec = sec - c;
      long long sum = sec * (sec + 1) / 2 - fir * (fir - 1) / 2;
      ans += sum;
    } else {
      long long fir = i + mn;
      long long sec = i + c;
      if (fir >= d + 1) {
        ans += (c - b + 1) * (d - c + 1);
        continue;
      }
      if (sec > d + 1) {
        ans += (sec - d - 1) * (d - c + 1);
        sec = d + 1;
      }
      fir = fir - c;
      sec = sec - c;
      long long sum = sec * (sec + 1) / 2 - fir * (fir - 1) / 2;
      ans += sum;
    }
  }
  cout << ans;
  return 0;
}
