#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long inf = 1ll << 62;
const int iinf = 0x7fffffff;
long long powmod(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) {
      ans *= a;
      ans %= mod;
    }
    b >>= 1;
    a *= a;
    a %= mod;
  }
  return ans;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; };
long long get_mm(long long a) {
  long long ans = 9;
  while (a) {
    ans = min(ans, a % 10);
    a /= 10;
  }
  return ans;
}
long long get_mx(long long a) {
  long long ans = 0;
  while (a) {
    ans = max(ans, a % 10);
    a /= 10;
  }
  return ans;
}
void solve() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = 0;
  for (int(i) = (a); (i) < (b + 1); (i)++) {
    long long bb = i + b - 1;
    long long cc = i + c - 1;
    if (bb <= c) {
      if (cc < d) {
        ans += (1 + cc - c + 1) * (cc - c + 1) / 2;
      } else {
        ans += (1 + d - c + 1) * (d - c + 1) / 2 + (cc - d) * (d - c + 1);
      }
    } else if (bb > c && bb <= d) {
      if (cc <= d) {
        ans += (bb - c + 1 + cc - c + 1) * (cc - bb + 1) / 2;
      } else {
        ans += (bb - c + 1 + d - c + 1) * (d - bb + 1) / 2 +
               (cc - d) * (d - c + 1);
      }
    } else {
      ans += (d - c + 1) * (cc - bb + 1);
    }
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) solve();
  return 0;
}
