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