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