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