#include #define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++) const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; typedef vector vi; typedef vector vll; typedef pair pii; int main() { cin.tie(0); ios::sync_with_stdio(false); int x, y, x2, y2; cin >> x >> y; cin >> x2 >> y2; if (x != y || x2 != y2) { cout << max(x, y) << endl; } else { if (x2 < x) { cout << x+1 << endl; } else { cout << x << endl; } } return 0; }