#include #include #include #include using namespace std; int main() { freopen("paint.in", "r", stdin); freopen("paint.out", "w", stdout); int a, b, c, d; cin >> a >> b >> c >> d; if (d < a || b < c) { cout << (b - a) + (d - c); } else { cout << abs(max(b, d) - min(a, c)); } }