import std.stdio, std.conv, std.string, std.range, std.math, std.algorithm; void main() { auto input = readln.split.to!(real[]); auto A = input[0], B = input[1], X = input[2], Y = input[3]; if (A > B) { swap(A, B); swap(X, Y); } auto rate = A / B; auto few = min(Y * rate, X); auto many = few / rate; "%.15s".writefln(few + many); }