A,B,N,M = map(int,input().split()) if A > B: #Aを交換 add = (A-B)//(N+1) elif A < B: add = (B-A)//(M+1) else: add = 0 ans = min(A,B) + add print(ans)