#include #include #include #include #include #include #include int howManyGames(int p, int d, int m, int s) { // Return the number of games you can buy int c=1,item=0; while(s>=p){ if(s>=p&&p>m){ s=s-p; p=p-d; if(p<=m){ p=m; } item++; } else { s=s-p; item++; } } return item; } 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; }