#include <bits/stdc++.h>
using namespace std;
long long sum[500101];
long long ans = 0, last = 0;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  for (int i = 1; i <= d; ++i) sum[i] = sum[i - 1] + i;
  long long y;
  for (int z = c; z <= d; ++z) {
    if (b + c <= z) break;
    int g = z - b + 1;
    int x = b - a + 1;
    if (g < b) {
      y = c - b + 1;
      long long k = min(b - g, x - 1);
      ans += k * y;
      x = x - k;
    } else
      y = c - g + 1;
    if (y <= x)
      ans += sum[y];
    else {
      ans += (sum[y] - sum[y - x]);
    }
  }
  cout << ans << endl;
  return 0;
}
