#include <bits/stdc++.h>
using namespace std;
const int max_node = 10000000;
long long tree[max_node];
long long lazy[max_node];
void updateRange(int node, int start, int _end, int l, int r, int val) {
  if (lazy[node] != 0) {
    tree[node] += (_end - start + 1) * lazy[node];
    if (start != _end) {
      lazy[node * 2] += lazy[node];
      lazy[node * 2 + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start > _end || start > r || _end < l) return;
  if (start >= l && _end <= r) {
    tree[node] += (_end - start + 1) * val;
    if (start != _end) {
      lazy[node * 2] += val;
      lazy[node * 2 + 1] += val;
    }
    return;
  }
  int mid = (start + _end) / 2;
  updateRange(node * 2, start, mid, l, r, val);
  updateRange(node * 2 + 1, mid + 1, _end, l, r, val);
  tree[node] = tree[node * 2] + tree[node * 2 + 1];
}
long long queryRange(int node, int start, int _end, int l, int r) {
  if (start > _end || start > r || _end < l) return 0;
  if (lazy[node] != 0) {
    tree[node] += (_end - start + 1) * lazy[node];
    if (start != _end) {
      lazy[node * 2] += lazy[node];
      lazy[node * 2 + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start >= l && _end <= r) return tree[node];
  int mid = (start + _end) / 2;
  long long x1 = queryRange(node * 2, start, mid, l, r);
  long long x2 = queryRange(node * 2 + 1, mid + 1, _end, l, r);
  return (x1 + x2);
}
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  long long ans = 0;
  int En = 1e6 + 5;
  for (int i = B; i <= C; i++) {
    int L = i + A;
    int R = i + B;
    updateRange(1, 1, En, L, R, 1);
  }
  for (int i = C; i <= D; i++) {
    ans += queryRange(1, 1, En, i + 1, En);
  }
  cout << ans << endl;
  return 0;
}
