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