#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int P = 1e9 + 7;
const int N = 2e7;
const int maxn = 1e6 + 5;
long long a, b, c, d;
int main() {
  ios::sync_with_stdio(false);
  cin >> a >> b >> c >> d;
  long long ans = 0;
  for (long long i = max(c + 1, a + b); i <= b + c; ++i)
    ans += (min(d + 1, i) - c) * (min(i - b, b) - max(i - c, a) + 1);
  cout << ans << endl;
}
