using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace yukicoderTest { class Program { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); int vegi = int.Parse(str[0]); int meat = int.Parse(str[1]); int d = int.Parse(str[2]); int total = int.Parse(str[3]); int cnt = 0; while (true) { if (total < d + vegi || meat < d) { break; } vegi--; meat -= d; total = total - d+vegi; cnt++; } Console.WriteLine(cnt); } } }