x, y = list(map(int, input().split(' '))) x2, y2 = list(map(int, input().split(' '))) if x == y and x2 == y2: print(x + 1) else: print(max([x, y]))