#include <bits/stdc++.h>
using namespace std;
long long int range[1000005];
void solve() {
  int A, B, C, D, i;
  cin >> A >> B >> C >> D;
  for (i = A; i <= B; i++) {
    range[i + B]++;
    range[i + C + 1]--;
  }
  for (i = 1; i < 1000005; i++) range[i] += range[i - 1];
  for (i = 1; i < 1000005; i++) range[i] += range[i - 1];
  long long int ans = 0;
  for (i = C; i <= D; i++) ans += range[1000005 - 1] - range[i];
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
