#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 10;
const long long INF = 1e18;
long long a, b, c, d, dp[maxn], sum[maxn], ans = 0;
long long f(long long z) {
  if (z > (b + c)) return 0;
  if ((a + b) > z) return 0;
  return min(z - b, b) - max(z - c, a) + 1;
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> a >> b >> c >> d;
  long long len1 = b - a + 1, len2 = c - b + 1, len3 = d - c + 1;
  ans = ((len1 * len2) * len3);
  for (long long i = 1; i < c; i++) {
    dp[i] = dp[i - 1] + f(i);
  }
  for (long long i = c; i <= d; i++) {
    dp[i] = dp[i - 1] + f(i);
    sum[i] = sum[i - 1] + dp[i];
  }
  ans -= sum[d];
  cout << ans;
  return 0;
}
