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