x, y = map(int,input().split()) x1, y1 = map(int,input().split()) if x == y and x1 == y1 and x1 < x: if x * x1 >= 0 and y * y1 > 0: print(x + 1) else: print(max(x, y)) else: print(max(x, y))