x, y = map(int, input().split()) x2, y2 = map(int, input().split()) if x != y: print(max(x, y)) else: if x2 != y2: print(x) elif x * x2 > 0 and y * y2 > 0: print(x + 1) else: print(x)