using System; using System.Linq; public class Program { public static void Main() { var lst = Console.ReadLine().Split(' '). Select(s => int.Parse(s)).ToList(); var a = lst[0]; var b = lst[1]; var c = lst[2]; var d = lst[3]; for (; ; ) { if ((a > 0) && (b >= c) && (d >= c + 1)) { a--; b -= c; d -= (c + 1); } else break; } Console.Write("{0}", (lst[0]-a).ToString()); return; } }