#include <bits/stdc++.h>
using namespace std;
long long A, B, C, D;
inline void solve() {
  long long ans = 0;
  for (long long x = A; x <= B; ++x) {
    long long st = max(C - x + 1, B);
    if (st + x <= D + 1) {
      long long len = min(C - st + 1, D + 1 - st + 1 - x);
      ans += len * (st + x - C) + len * (len - 1) / 2;
    }
    if (C + x >= D + 2) {
      long long len = C - max(D + 2 - x, B) + 1;
      ans += len * (D + 1 - C);
    }
  }
  printf("%lld\n", ans);
}
int main(void) {
  scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
  solve();
  return 0;
}
