x, y = map(int, input().split()) x2, y2 = map(int, input().split()) a = min(x, y) b = max(x, y) - a ans = a + b if x == y and x2 == y2 and x2 < x: ans += 1 print(ans)