#include <bits/stdc++.h>
using namespace std;
bool prime(long long int s) {
  if (s <= 1) return false;
  if (s <= 3) return true;
  if (s % 2 == 0 || s % 3 == 0) return false;
  for (long long int i = 5; i * i <= s; i = i + 6)
    if (s % i == 0 || s % (i + 2) == 0) return false;
  return true;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
const long long int MAX = 1e7;
long long int arr[MAX];
long long int pref[MAX];
void solve() {
  long long int a, b, c, d, ans = 0;
  cin >> a >> b >> c >> d;
  for (long long int i = a; i <= b; ++i) {
    long long int u = i + b;
    long long int v = i + c + 1;
    arr[u]++;
    arr[v]--;
  }
  for (long long int i = 1; i < MAX; ++i) {
    arr[i] += arr[i - 1];
  }
  pref[0] = arr[0];
  for (long long int i = 1; i < MAX; ++i) {
    pref[i] = pref[i - 1] + arr[i];
  }
  for (long long int i = c; i <= d; ++i) {
    ans += pref[MAX - 1] - pref[i];
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
