#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long extended_gcd(long long a, long long b, long long& x, long long& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long x1, y1;
  long long d = extended_gcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - y1 * (a / b);
  return d;
}
vector<int> sieveoferatosthenes(int n) {
  vector<bool> prime(n + 1, true);
  for (int i = 2; i <= sqrt(n); i++) {
    if (prime[i]) {
      for (int j = i * i; j <= n; j += i) {
        prime[j] = false;
      }
    }
  }
  vector<int> all_primes;
  for (int i = 2; i <= n; i++) {
    if (prime[i]) all_primes.push_back(i);
  }
  return all_primes;
}
long long bin_exp(long long a, long long b, long long mod) {
  long long ans = 1;
  while (b) {
    if (b % 2) {
      b--;
      ans = (ans % mod * a % mod) % mod;
    }
    b /= 2;
    a = (a % mod * a % mod) % mod;
  }
  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 minim = a + b, maxim = b + c, k = 0, ans = 0;
  map<long long, long long> count;
  for (int i = minim; i <= (maxim + minim) / 2; i++) {
    k++;
    count[i] = min(k, min(b - a + 1, c - b + 1));
  }
  k = (maxim - minim + 1) / 2;
  for (int i = (maxim + minim) / 2 + 1; i <= maxim; i++) {
    count[i] = min(k, min(b - a + 1, c - b + 1));
    k--;
  }
  for (auto i : count) {
    if (i.first > d)
      ans += (i.second) * (d - c + 1);
    else if (i.first <= d and i.first >= c)
      ans += (i.second) * (i.first - c);
    else
      ans += 0;
  }
  cout << ans << endl;
  return 0;
}
