#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 10;
int pre[maxn];
int main() {
  long long a, b, c, d, ans = 0;
  cin >> a >> b >> c >> d;
  for (int i = a; i <= b; i++) pre[i + b]++, pre[i + c + 1]--;
  for (int i = 1; i < maxn; i++) pre[i] += pre[i - 1];
  for (int i = 0; i < maxn; i++)
    ans += pre[i] * max(0ll, min(d, (long long)(i - 1)) - c + 1);
  cout << ans;
  return 0;
}
