#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '{';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
void dbg_out() { cerr << "\n"; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
long long sum[1000005];
void solve() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  for (long long i = a; i <= b; i++) {
    sum[i + c + 1] -= 1;
    sum[i + b] += 1;
  }
  for (long long i = 1; i <= 1000000; i++) {
    sum[i] += sum[i - 1];
  }
  long long tot = 0;
  for (long long i = 1; i <= 1000000; i++) {
    long long upper = i - 1;
    upper = min(upper, d);
    if (upper >= c) {
      tot += (upper - c + 1) * sum[i];
    }
  }
  cout << tot << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}
