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