A,B,X,Y=map(int,input().split()) ANS=0 if X*B/A<=Y: ANS=max(ANS,X*(1+B/A)) if Y*A/B<=X: ANS=max(ANS,Y*(1+A/B)) print(ANS)