a , b , x , y = map(int,input().split()) x1 = a * y / b y1 = b * x / a if x1 > x: x1 = 0 if y1 > y: y1 = 0 ans = max(x1 + y , x + y1) print(ans)