#include #include #include #include #include #include #include #include #include #include using namespace std; int main(){ int x,y; cin >> x >> y; int c,r; cin >> c >> r; int ans = max(x,y); if((x == c && x == 0 && r < y) || (y == r && y == 0 && c < x)) ans += 1; else if( x==y && c==r && c < x ) ans += 1; cout << ans << endl; return 0; }