#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long a, b, c, d, x1, x2, y1, y2, tmp, t = 0, i;
  cin >> a >> b >> c >> d;
  for (i = a; i <= b; i++) {
    x1 = c;
    x2 = d - (i - 1);
    if (x2 >= x1) {
      y1 = ((c + i - 1) - c) + 1;
      y2 = (c - b) + 1;
      if (y2 >= y1)
        t += (y1 * (y1 + 1)) / 2;
      else
        t += ((y1 * (y1 + 1)) / 2) - (((y1 - y2) * ((y1 - y2) + 1)) / 2);
    } else {
      y1 = x1 - x2;
      y2 = (c - b) + 1;
      if (y1 > y2) {
        t += y2 * (d - c + 1);
      } else {
        t += y1 * (d - c + 1);
        tmp = y2 - y1;
        y1 = (d - c + 1);
        y2 = tmp;
        if (y2 >= y1)
          t += (y1 * (y1 + 1)) / 2;
        else
          t += ((y1 * (y1 + 1)) / 2) - (((y1 - y2) * ((y1 - y2) + 1)) / 2);
      }
    }
  }
  cout << t << "\n";
  return 0;
}
