def solve(a: int, b: int, c: int, d: int) -> int: if a == 0 and d < b: return b elif b == 0 and c < a: return a elif a == b and c == d and c < a: return a + 1 else: return max(a, b) x: int y: int x, y = map(int, input().split()) x2: int y2: int x2, y2 = map(int, input().split()) print(solve(x, y, x2, y2))