#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-O3")
mt19937 rnd(time(NULL));
vector<long long> q;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = 0;
  for (long long y = b; y <= c; y++) {
    long long L = c - y;
    long long R = d - y;
    long long l = a;
    long long r = b;
    l = max(l, L);
    if (l > R) {
      ans += (R - L + 1) * (r - l + 1);
      continue;
    }
    if (r <= L) continue;
    long long start = l - L;
    long long finish = min(R - L, r - l) + start;
    finish = min(finish, R - L);
    long long ans1 = finish * (finish + 1) / 2 - start * (start - 1) / 2;
    long long ans2 = 0;
    long long cnt = r - R;
    if (cnt > 0) ans2 = cnt * (R - L + 1);
    ans += ans1 + ans2;
  }
  cout << ans << endl;
}
