#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e18;
const int OFF = (1 << 20);
int a, b, c, d;
long long loga[1000002];
long long p[1000002];
void update(int x, int y) {
  for (x; x <= 1000000; x += x & -x) loga[x] += y;
}
long long query(int x) {
  long long out = 0;
  for (x; x > 0; x -= x & -x) out += loga[x];
  return out;
}
int main() {
  cin >> a >> b >> c >> d;
  for (int i = a; i <= b; i++) {
    p[i + b]++;
    p[i + c + 1]--;
  }
  for (int i = 1; i <= 1000000; i++) {
    p[i] += p[i - 1];
    update(i, p[i]);
  }
  long long sol = 0;
  for (int i = c; i <= d; i++) {
    long long tren = query(1000000);
    tren -= query(i);
    sol += tren;
  }
  cout << sol;
  return 0;
}
