using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { // p - starting price // d - discount on the next game // m - min price // s - how much money you have static int howManyGames(int p, int d, int m, int s) { // Return the number of games you can buy bool canBuyGames = true; int numOfGames = 0; while (canBuyGames) { if ((s-p) >= 0) { numOfGames++; s -= p; if((p-d > m)) { p -= d; } else { p = m; } } else { canBuyGames = false; } } return numOfGames; } static void Main(String[] args) { 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); } }