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 sum = 0; int n = b / c; int u = a - n; sum = (a-u) + b; if (d> b) { Console.WriteLine(count); } else { if (sum > d) { for (; ; ) { sum -= c; n -= 1; if (sum < d) { count = n; break; } } } else if (n >= a) { count = a; } else { count = n; } Console.WriteLine(count); } } } }