#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
using namespace std;
const long long MOD = 1e+9 + 7;
const long long INF = LLONG_MAX;
const int INFi = INT_MAX;
const long long N = 3e+5 + 8;
vector<long long> adj[N];
long long vis[N];
long long dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};
long long test_cases = 1;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
;
long long n, a[N];
void MAIN(long long tc) {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long res = 0;
  for (long long x = (a); x <= b; x++) {
    long long my = c, sum, g, g2;
    if (x + c <= d) {
      sum = x + my;
      g = sum - c;
      g2 = c - b + 1;
      if (g2 >= g)
        g2 = 0;
      else
        g2 = g - g2;
      res += (g) * (g + 1) / 2 - g2 * (g2 + 1) / 2;
    } else {
      sum = x + my;
      g = (d - c + 1);
      g2 = my - b + 1;
      long long sp = sum - d;
      if (g2 >= sp) {
        res += g * sp;
        g2 -= sp;
        g--;
        if (g2 >= g)
          g2 = 0;
        else
          g2 = g - g2;
        res += (g) * (g + 1) / 2 - g2 * (g2 + 1) / 2;
      } else {
        res += g * g2;
        g2 = 0;
      }
    }
  }
  cout << res;
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(10);
  ;
  for (long long i = (1); i <= test_cases; i++) {
    MAIN(i);
  }
}
