a,b,n,m=map(int,input().split()) c=min(a,b) a-=c b-=c c+=a//(n+1)+b//(m+1) print(c)