#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
int a, b, c, d;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> b;
  cin >> c >> d;
  long long ans = 0;
  for (int i = a; i <= b; i++) {
    int mi = b;
    mi = max(c - i + 1, mi);
    int mx = c;
    if (mi <= mx) {
      int t0 = min(i + mi - 1, d) - c + 1;
      int t1 = min(i + mx - 1, d) - c + 1;
      ans += (t0 + t1) * 1LL * (t1 - t0 + 1) / 2;
      if (mx - mi + 1 > (t1 - t0 + 1))
        ans += (mx - mi + 1 - (t1 - t0 + 1)) * 1LL * (d - c + 1);
    }
  }
  cout << ans << "\n";
  return 0;
}
