#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int main(){ ll a,b,c,d; cin >> a >> b >> c >> d; if(a > c)swap(a,c),swap(b,d); cout << b - a + 1 + d - c + 1 + max((ll)0,b - c + 1) << endl; }