#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
struct custom_hash {
  static unsigned long long splitmix64(unsigned long long x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(unsigned long long x) const {
    static const unsigned long long FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
mt19937 random_generator(
    chrono::steady_clock::now().time_since_epoch().count());
int a, b, c, d;
void read() { cin >> a >> b >> c >> d; }
long long sum(int l, int r) { return 1ll * (l + r) * (r - l + 1) / 2ll; }
void solve() {
  long long ans = 0;
  for (int x = a; x <= b; x++) {
    int bound1 = max(b, d - x + 2);
    ans += 1ll * max(0, c - bound1 + 1) * (d - c + 1);
    int bound2 = max(c - x + 1, b);
    bound1--;
    bound1 = min(bound1, c);
    if (bound2 > bound1) continue;
    ans += 1ll * (bound1 - bound2 + 1) * (x - c) + sum(bound2, bound1);
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  read();
  solve();
}
