#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int inf = 1e17;
const long long int N = 1e7;
long long int pref[N], dp[N];
void __solve() {
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;
  for (long long int i = a; i <= b; i++) {
    pref[i + b]++;
    pref[i + c + 1]--;
  }
  for (long long int i = 1; i < N; i++) {
    pref[i] += pref[i - 1];
  }
  long long int ans = 0;
  for (long long int i = N - 2; i >= c; i--) {
    dp[i] = dp[i + 1] + pref[i];
  }
  for (long long int i = c; i <= d; i++) {
    ans += dp[i + 1];
  }
  cout << ans;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  while (T--) {
    __solve();
    cout << '\n';
  }
}
