#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
vector<complex<double> > FFT(vector<complex<double> > ar, int inv) {
  int i, j, l, len, n = ar.size();
  const double p = 4.0 * inv * acos(0.0);
  for (i = 1, j = 0; i < n; i++) {
    for (l = n >> 1; j >= l; l >>= 1) j -= l;
    j += l;
    if (i < j) swap(ar[i], ar[j]);
  }
  for (l = 1, len = 2; len <= n; l <<= 1, len <<= 1) {
    double theta = p / len;
    complex<double> mul(cos(theta), sin(theta));
    for (i = 0; i < n; i += len) {
      complex<double> w(1.0, 0.0);
      for (j = 0; j < l; j++) {
        complex<double> u = ar[i + j], v = ar[i + j + l] * w;
        ar[i + j] = u + v, ar[i + j + l] = u - v;
        w *= mul;
      }
    }
  }
  if (inv == -1) {
    for (i = 0; i < n; i++) ar[i] /= n;
  }
  return ar;
}
vector<complex<double> > multiply(vector<complex<double> > A,
                                  vector<complex<double> > B) {
  int n, m, i;
  vector<complex<double> > C;
  n = A.size() + B.size() - 1;
  m = 1 << (32 - __builtin_clz(n) - (__builtin_popcount(n) == 1));
  A.resize(m, 0), B.resize(m, 0), C.resize(m, 0);
  A = FFT(A, 1), B = FFT(B, 1);
  for (i = 0; i < m; i++) C[i] = A[i] * B[i];
  return FFT(C, -1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c, d;
  while (cin >> a) {
    cin >> b >> c >> d;
    vector<complex<double> > A(500002), B(500002);
    for (int i = a; i <= b; i += 1) {
      A[i] = 1;
    }
    for (int i = b; i <= c; i += 1) {
      B[i] = 1;
    }
    vector<complex<double> > res = multiply(A, B);
    long long cnt = 0;
    for (int i = 0; i < res.size(); i += 1) {
      int now = round(res[i].real());
      if (now) {
        if (i >= c) {
          int r = min(i - 1, d);
          if (r >= c) {
            cnt += ((long long)now * (r - c + 1));
          }
        }
      }
    }
    cout << cnt << endl;
  }
}
