#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000 * 1000 * 1000 + 7;
const long long int INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const long long int MOD2 = 998244353;
const long double PI = 3.141592653589793;
long long int gcd(long long int a, long long int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int power1(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;
  long long int ans = 0;
  for (long long int i = b; i >= a; i--) {
    if (c - (d - i) > 0) {
      if (d - i < b) {
        ans = ans + (c - b + 1) * (d - c + 1);
        continue;
      }
      ans = ans + (c - (d - i)) * (d - c + 1);
      long long int temp = d - c;
      long long int num = d - i - b + 1;
      if (num >= temp)
        ans = ans + (temp * (temp + 1)) / 2;
      else {
        long long int temp1 = temp - num;
        ans = ans + (temp * (temp + 1)) / 2 - (temp1 * (temp1 + 1)) / 2;
      }
    } else {
      long long int temp = i;
      long long int num = c - b + 1;
      if (num >= temp)
        ans = ans + (temp * (temp + 1)) / 2;
      else {
        long long int temp1 = temp - num;
        ans = ans + (temp * (temp + 1)) / 2 - (temp1 * (temp1 + 1)) / 2;
      }
    }
  }
  cout << ans << "\n";
}
