#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void read(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void Read(T&... args) {
  ((getline(cin, args)), ...);
}
template <typename... T>
void write(T&&... args) {
  ((cout << args << ""), ...);
}
bool check(long long n, long long pos) { return (n & (1 << pos)); }
bool Set(long long n, long long pos) { return (n | (1 << pos)); }
long double LOG(long double b, long double e) { return log(b) / log(e); }
int tc = 1;
long long cnt[1000077 + 5];
void solve(int kk) {
  int a, b, c, d;
  read(a, b, c, d);
  for (int i = a; i <= b; i++) cnt[i + b]++, cnt[i + c + 1]--;
  for (int i = 1; i < 1000077; i++) cnt[i] += cnt[i - 1];
  for (int i = 1; i < 1000077; i++) cnt[i] += cnt[i - 1];
  long long ans = 0;
  for (int i = c; i <= d; i++) {
    ans += (cnt[1000077 - 1] - cnt[i]);
  }
  write(ans);
  cout << "\n";
}
int main() {
  int kk = 0;
  while (++kk <= tc) solve(kk);
  return 0;
}
