#include using namespace std; int main(){ int s,t; cin >> s >> t; int x,y; cin >> x >> y; if(s==t&&x==y&&s>y){ cout << max(s,t)+1 << endl; }else{ cout << max(s,t) << endl; } }