#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = 0LL;
  for (long long i = a; i < b + 1; ++i) {
    long long B = max(b, c - i + 1);
    long long D = c - B + 1;
    long long least = min(d + 1, B + i);
    long long most = min(d + 1, c + i);
    long long l = least - c - 1;
    long long m = most - c;
    long long r = D - (most - least + 1);
    ans += m * (m + 1) / 2 - l * (l + 1) / 2;
    ans += m * r;
  }
  cout << ans << '\n';
  return 0;
}
