#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e6 + 7;
long long p[N];
int main() {
  int a, b, c, d;
  scanf("%d", &a), scanf("%d", &b), scanf("%d", &c), scanf("%d", &d);
  for (int i = a; i < (int)b + 1; i++) {
    p[i + b] += 1;
    p[i + c + 1] -= 1;
  }
  for (int i = 1; i < (int)N; i++) p[i] += p[i - 1];
  for (int i = 1; i < (int)N; i++) p[i] += p[i - 1];
  long long val = 0;
  for (int i = c; i < (int)d + 1; i++) val += p[N - 1] - p[i];
  printf("%lld\n", val);
}
