#include <bits/stdc++.h>
using namespace std;
long long s(int n, long long* cnt) {
  if (n <= 0) return 0;
  return cnt[n];
}
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  const int N = 1e6 + 5;
  long long cnt[N];
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < N; i++) {
    cnt[i] += max(0, i - c);
    if (i > d) cnt[i] -= (i - d - 1);
  }
  for (int i = 1; i < N; i++) cnt[i] += cnt[i - 1];
  long long ans = 0;
  for (int k = b; k <= c; k++) {
    int tempA = a + k;
    int tempB = b + k;
    ans += s(tempB, cnt) - s(tempA - 1, cnt);
  }
  cout << ans;
  return 0;
}
