import java.io.*;
import java.util.*;
import java.math.*;

class Main236 {
	
	public static void out (Object out) {
		System.out.println(out);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		String[] line = br.readLine().split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		int x = Integer.parseInt(line[2]);
		int y = Integer.parseInt(line[3]);
		
		if (a < b) {
			double d = (double)y / b * a;
			out(d <= x ? y + d : x + ((double)x / a * b));
		} else if (b < a) {
			double d = (double)x / a * b;
			out(d <= y ? x + d : y + ((double)y / a * b));
		} else {
			out(Math.min(x , y) * 2);
		}
		
	}
}