#include <bits/stdc++.h>
using namespace std;
const long long base = 233;
const long long ff = 4e5 + 1;
const long long mod = 1e9 + 7;
const long long inf = 1e17 + 1;
long long read() {
  long long x;
  scanf("%lld", &x);
  return x;
}
inline long long Read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long a, b, c, d;
long long my_max(long long x, long long y) { return (x > y) ? x : y; }
void init() {
  long long ans = 0;
  a = Read(), b = Read(), c = Read(), d = Read();
  for (long long i = a; i <= b; ++i) {
    long long st = my_max(min(i + b - c, d), 0LL);
    long long ed = my_max(min(i + c - 1, d) - c + 1, 0LL);
    long long q = max(ed - st + 1, 0LL);
    ans += (st + ed) * q / 2;
    if (i + c - 1 > d)
      ans += my_max(min((i + c - 1) - d, c - b + 1), 0LL) * (d - c + 1);
  }
  cout << ans;
}
signed main() { init(); }
