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