using System.Numerics; public class Program { public static void Main() { //BigInteger num = BigInteger.Parse(Console.ReadLine() ?? string.Empty); //int num = int.Parse(Console.ReadLine() ?? string.Empty); string[] str = (Console.ReadLine() ?? string.Empty).Trim().Split(' '); //string str = Console.ReadLine() ?? string.Empty; int a = int.Parse(str[0]); int b = int.Parse(str[1]); int c = int.Parse(str[2]); int d = int.Parse(str[3]); if(a > c||b > d) { Console.WriteLine(0); } else if(a!=0&&a ==c || b!=0&&b ==d) { Console.WriteLine(1); } else { if(a==0) { Console.WriteLine(d / b); return; } else if(b==0) { Console.WriteLine(c / a); return; } int e = c / a; int f = d / b; if(e > f) { Console.WriteLine(f); } else { Console.WriteLine(e); } } } }