#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 6;
int t[MAXN], p[MAXN];
int a, b, c, d;
void solve();
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> a >> b >> c >> d;
  solve();
  return 0;
}
void solve() {
  for (int i = a; i <= b; i++) {
    t[i + b]++;
    t[i + c + 1]--;
  }
  for (int i = a + b; i <= b + c + 1; i++) {
    t[i] += t[i - 1];
  }
  long long ans = 0, cnt = 0;
  for (int i = b + c + 1; i >= c; i--) {
    if (i <= d && i >= c) {
      ans += cnt;
    }
    cnt += t[i];
  }
  cout << ans << endl;
}
