#include <bits/stdc++.h>
using namespace std;
void print1(vector<int> X) {
  for (int i = 0; i < X.size(); i++) {
    cout << X[i] << " ";
  }
  cout << endl;
  return;
}
void print2(vector<vector<int>> X) {
  for (int i = 0; i < X.size(); i++) {
    for (int j = 0; j < X[i].size(); j++) {
      cout << X[i][j] << " ";
    }
    cout << endl;
  }
  return;
}
long long int suma(long long int k) {
  if (k <= 0) {
    return 0;
  }
  return (k * (k + 1)) / 2;
}
long long int s(long long int an, long long int did, long long int kiek) {
  if (kiek <= did - an + 1) {
    return suma(an + kiek - 1) - suma(an - 1);
  }
  return suma(did) - suma(an - 1) + (max(0LL, kiek - (did - an + 1)) * did);
}
long long int solve(long long int n, long long int m, long long int d) {
  long long int p = max(d - m + 1, 0LL);
  if (d < 0) {
    return (n + 1) * (m + 1);
  }
  if (d == 0) {
    return (n + 1) * (m + 1) - 1;
  }
  long long int an = m + 1 - (d + 1 - p);
  return s(an, m + 1, n + 1 - p);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int A, B, C, D;
  cin >> A >> B >> C >> D;
  long long int ats = 0;
  for (int n = C; n <= D; n++) {
    long long int x = solve(B - A, C - B, n - A - B);
    ats = ats + x;
  }
  cout << ats << endl;
  return 0;
}
