#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000002;
const int MOD = 1000000007;
const double EPS = 1e-9;
long long acm[MAXN], aacm[MAXN];
int main() {
  int a, b, c, d;
  scanf("%d", &a), scanf("%d", &b);
  scanf("%d", &c), scanf("%d", &d);
  for (int i = c; i < MAXN; i++) {
    acm[i] = acm[i - 1];
    if (i <= d) acm[i]++;
    aacm[i] = acm[i] + aacm[i - 1];
  }
  long long res = 0;
  for (int i = a; i <= b; i++) {
    res += aacm[i + c - 1] - aacm[i + b - 2];
  }
  printf("%lld\n", res);
  return 0;
}
