x, y = map(int, input().split())
x2, y2 = map(int, input().split())

if abs(x) == abs(y) and x*y2 == x2*y:
    ans = max(x, y) + 1
else:
    ans = max(x, y)

print(ans)