#include <bits/stdc++.h>
using namespace std;
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
using LL = int_fast64_t;
const int MAXN = 5e5 + 7;
int a, b, c, d;
int cnt[MAXN];
int main() {
  ____();
  cin >> a >> b >> c >> d;
  for (int i = 0; i <= min(c - b, d - c); i++) cnt[i] = i + 1;
  for (int i = min(c - b, d - c); i <= max(c - b, d - c); i++)
    cnt[i] = min(c - b, d - c) + 1;
  for (int i = max(c - b, d - c); i <= d - b; i++) cnt[i] = d - b - i + 1;
  LL ret = 0;
  for (int i = 0; i < MAXN; i++) {
    if (!cnt[i]) continue;
    int h = i + 1;
    if (i + 1 > b)
      continue;
    else
      ret += 1ll * (b - max(h, a) + 1) * cnt[i];
  }
  cout << ret << endl;
  return 0;
}
