#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 total=0,count=0,present=p; while(s>=total) { count++; total=total+present; if((present-d)>m) present = present-d; else present =m; //total=total+present; } return count-1; } 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; }