#include using namespace std; int main() { int a, b, c, d; int ans; cin >> a >> b >> c >> d; if (b < c || d < a) { ans = (b - a + 1) * (d - c + 1); } else if (c <= b && b <= d) { ans = (c - a) * (d - c + 1) + (b - c + 1) * (d - c); } else { ans = (a - c) * (b - a + 1) + (d - a + 1) * (b - a); } cout << ans << endl; return 0; }