#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ii = pair<int, int>;
const int MAXN = 1e6 + 10;
int p[MAXN];
int main() {
  ios::sync_with_stdio(true);
  cin.tie(nullptr);
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  for (int x = A; x <= B; ++x) {
    ++p[x + B];
    --p[x + C + 1];
  }
  ll ans = 0;
  for (int xy = 1; xy < MAXN; ++xy) {
    p[xy] += p[xy - 1];
    ans += max(0LL, p[xy] * 1LL * (min(xy, D + 1) - C));
  }
  cout << ans << '\n';
  return 0;
}
