#include <bits/stdc++.h>
using namespace std;
long long powerm(long long x, unsigned long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long power(long long x, unsigned long long y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long gcdExtended(long long a, long long b, long long *x, long long *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long modInverse(long long a, long long m) {
  long long x, y;
  long long g = gcdExtended(a, m, &x, &y);
  if (g != 1)
    cout << "Inverse doesn't exist";
  else {
    long long res = (x % m + m) % m;
    return res;
  }
}
long long vis[500001];
long long par[200001];
long long tin[200001];
long long tout[200001];
long long t = 0;
long long a[500001];
long long c[500001];
long long ans[200001];
struct setcmp {
  bool operator()(pair<long long, long long> x, pair<long long, long long> y) {
    return (x.first < y.first || (x.first == y.first && x.second < y.second));
  }
};
void dfs(long long i, long long p, vector<long long> adj[], long long &f) {
  vis[i] = 1;
  for (long long j = 0; j < adj[i].size(); j++) {
    long long u = adj[i][j];
    if (u == p) continue;
    if (vis[u] == 0) dfs(u, i, adj, f);
  }
}
bool cmp(long long x, long long y) { return a[x] < a[y]; }
void solve() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long z[1000005] = {0};
  for (long long i = a; i <= b; i++) {
    z[i + b]++;
    z[i + c + 1]--;
  }
  for (long long i = 1; i < 1000005; i++) z[i] = z[i - 1] + z[i];
  for (long long i = 1000003; i >= c; i--) z[i] = z[i + 1] + z[i];
  long long ct = 0;
  for (long long i = c; i <= d; i++) ct += z[i + 1];
  cout << ct;
}
int32_t main() {
  long long q = 1;
  long long Q = 1;
  while (q--) {
    solve();
    cout << "\n";
  }
}
