#include <bits/stdc++.h>
using namespace std;
long long powM(long long a, long long b, long long m) {
  a %= m;
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = 0;
  long long p = 1e9 + 7;
  for (long long s = a + b; s <= b + c; s++) {
    long long temp = max(0LL, s - c);
    temp = min(temp, d - c + 1);
    long long l = max(0LL, s - a - c);
    long long r = min(s - a - b, b - a);
    long long cnt = r - l + 1;
    ans += cnt * temp;
  }
  cout << ans << "\n";
  return 0;
}
