static void Main(string[] args) { var R = Scan.BigInt(); var B = Scan.BigInt(); var x = Scan.BigInt(); var y = Scan.BigInt(); var max_r = R / x; var max_b = B / y; if (max_r == 0 && max_b == 0) { Console.WriteLine(0); } else if (max_r == 0) { Solve(B, R, y, x); } else { Solve(R, B, x, y); } }