#include <bits/stdc++.h>
using namespace std;
int dir[4][2] = {{1, 0}, {0, 1}, {0, -1}, {-1, 0}};
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979323846;
const double eps = 1e-6;
const int mod = 1e9 + 7;
const int N = 5e5 + 5;
inline long long read() {
  long long x = 0;
  bool f = true;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = false;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return f ? x : -x;
}
long long gcd(long long m, long long n) { return n == 0 ? m : gcd(n, m % n); }
long long lcm(long long m, long long n) { return m * n / gcd(m, n); }
bool prime(int x) {
  if (x < 2) return false;
  for (int i = 2; i * i <= x; ++i) {
    if (x % i == 0) return false;
  }
  return true;
}
long long qpow(long long m, long long k, long long mod) {
  long long res = 1, t = m;
  while (k) {
    if (k & 1) res = res * t % mod;
    t = t * t % mod;
    k >>= 1;
  }
  return res;
}
long long sum[N], cnt[N], tot;
int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long l = -1, r = d - b + 1, mx = min(d - c + 1, c - b + 1);
  while (r > l) {
    tot++;
    r--, l++;
    cnt[r] = cnt[l] = min(tot, mx);
  }
  sum[0] = cnt[0];
  for (int i = 1; i <= d; i++) {
    sum[i] = sum[i - 1] + cnt[i];
  }
  long long ans = 0;
  for (int i = a; i <= b; i++) {
    ans += sum[i - 1];
  }
  cout << ans << endl;
  return 0;
}
