A,B,N,M=map(int,input().split()) ans=min(A,B) A-=ans B-=ans if(A>0): ans+=A//(N+1) if(B>0): ans+=B//(M+1) print(ans)