#include <bits/stdc++.h>
using namespace std;
int A, B, C, D;
int main() {
  while (scanf("%d %d %d %d", &A, &B, &C, &D) == 4) {
    vector<int> d(D - B + 1, 0);
    for (int td = 0; td <= D - B; td++)
      d[td] = min(min(td, D - B - td), min(C - B, D - C)) + 1;
    vector<long long> sd(D - B + 1, 0);
    for (int td = 0; td <= D - B; td++) sd[td] = (td ? sd[td - 1] : 0) + d[td];
    long long res = 0;
    for (int x = A; x <= B; x++) res += sd[min(x - 1, (int)sd.size() - 1)];
    cout << res << "\n";
  }
}
