#include <bits/stdc++.h>
using namespace std;
bool check(long long a, long long b, long long c) {
  if (a + b > c)
    return true;
  else
    return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long a, b, c, d, ans = 0;
  cin >> a >> b >> c >> d;
  for (long long i = b; i <= c; ++i) {
    if (a + i > d)
      ans += (d - c + 1ll) * (b - a + 1ll);
    else if (a + i <= c) {
      long long L = max(b - d + i, 0ll), R = max(b - c + i, 0ll);
      ans += (L + R) * (R - L + 1ll) / 2ll;
    } else {
      long long range = a + i;
      ans += (range - c) * (b - a + 1ll);
      long long L = max(b - d + i, 0ll), R = max(b - range + i, 0ll);
      ans += (L + R) * (R - L + 1ll) / 2ll;
    }
  }
  cout << ans;
  return 0;
}
