using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static int HowManyGames(int startPrize, int cheaper, int minPrize, int money) { var bought = 0; var stillCanBuy = true; if(money >= startPrize) { bought++; money -= startPrize; } else { stillCanBuy = false; } while(stillCanBuy) { if(startPrize - cheaper > minPrize) { startPrize -= cheaper; if(startPrize <= money) { bought++; money -= startPrize; } else { stillCanBuy = false; } } else { startPrize = minPrize; if (startPrize <= money) { bought++; money -= startPrize; } else { stillCanBuy = false; } } } return bought; } static void Main() { string[] tokens_p = Console.ReadLine().Split(' '); int p = Convert.ToInt32(tokens_p[0]); int d = Convert.ToInt32(tokens_p[1]); int m = Convert.ToInt32(tokens_p[2]); int s = Convert.ToInt32(tokens_p[3]); int answer = HowManyGames(p, d, m, s); Console.WriteLine(answer); Console.ReadLine(); } }