import java.util.*; public class Exercise66{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); double a = sc.nextInt(); double b = sc.nextInt(); double x = sc.nextInt(); double y = sc.nextInt(); double sum = 0; if(a == b){ double min = Math.min(x, y); sum = min * 2; int sumd = (int)sum; System.out.println(sumd); }else{ double xd = (y * a) / b; if (xd > x){ double yd = (x * b) /a; sum = x + yd; }else{ sum = y + xd; } System.out.println(sum); } } }