x, y = map(int, input().split()) xx, yy = map(int, input().split()) if x == y and xx == yy and x > xx: print(x + 1) else: print(max(x, y))