#include <bits/stdc++.h>
using namespace std;
const int MX = 200005;
const long long MOD = 998244353;
void setIO(string name) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  freopen((name + ".in").c_str(), "r", stdin);
  freopen((name + ".out").c_str(), "w", stdout);
}
int a, b, c, d;
long long y[1000005];
void solve() {}
int main() {
  cin >> a >> b >> c >> d;
  for (int i = 0; i < (a + b); i++) y[i] = 0;
  for (int i = (a + b); i < (b + c + 1); i++) {
    long long l = max(a, i - c), r = min(b, i - b);
    y[i] = y[i - 1] + (r - l + 1);
  }
  long long ans = 0;
  for (int i = (c); i < (min(d + 1, b + c)); i++) {
    ans += y[b + c] - y[i];
  }
  cout << ans << endl;
}
