a, b, n, m = map(int, input().split()) if a < b: print(a + int(abs((b - a) / (m + 1)))) else: print(b + int(abs(a - b) / (n + 1)))