using System; namespace yukicoder { class Program { static void Main(string[] args) { string[] s = Console.ReadLine().Split(' '); int a = int.Parse(s[0]);//目の前の野菜 int b = int.Parse(s[1]);//目の前の肉 int c = int.Parse(s[2]);//1つの野菜を食べるための肉の数 int d = int.Parse(s[3]);//最大数 int count = 0; int n = b / c; for (int i = 0; i < a; i++) { b -= c; if (b < 0) { break; } count++; if (b == 0) { break; } } if ( (count*c) + n > d) { for (; ; ) { int sum = (count * c) + n; sum -= c; count -= 1; if ( sum< d) { break; } } } Console.WriteLine(count); } } }