#include <bits/stdc++.h>
using namespace std;
long long qzz[600005];
int main() {
  int i, j, m, t, n, s;
  long long a, b, c, d;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
  unsigned long long sum = 0;
  for (i = a; i <= b; i++) {
    if (i == a) {
      for (j = 1; j <= d + 3; j++) {
        qzz[j] = qzz[j - 1] + j;
      }
    }
    int qd = b;
    if (qd < c - i + 1) qd = c - i + 1;
    if (i + qd > d) {
      sum += (long long)(d - c + 1) * (c - qd + 1);
    } else {
      int zd = i + qd - c;
      if (i + c <= d) {
        int wei = i;
        sum += qzz[wei] - qzz[zd - 1];
      } else {
        int wei = d - c + 1;
        sum += qzz[wei] - qzz[zd - 1];
        sum += (long long)((c - qd + 1) - (wei - zd + 1)) * wei;
      }
    }
  }
  cout << sum << endl;
  return 0;
}
