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