#include #include #include #include #include #include #include int howManyGames(int p, int d, int m, int s) { int a=0; while(s>=m) { p=p-a*d; if(p>m) { s=s-p; a++; } else { s=s-m;a++;} } return(a-2); // Return the number of games you can buy } int main() { int p; int d; int m; int s; scanf("%i %i %i %i", &p, &d, &m, &s); int answer = howManyGames(p, d, m, s); printf("%d\n", answer); return 0; }