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