s = gets.to_s.split a = s[0].to_i b = s[1].to_i x = s[2].to_i y = s[3].to_i r1 = b.to_f / a r2 = a.to_f / b c1 = x * r1 c2 = y * r2 if c1 > y puts y + c2 else puts x + c1 end