#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 cost_of_game=p,number_of_games=0,flag=0; while(1) { if(cost_of_game>s) { break; } else { number_of_games+=1; if(flag==0) { s-=cost_of_game; cost_of_game-=d; if(cost_of_game<=m) { flag=1; cost_of_game=m; } } else { s-=cost_of_game; } } } return number_of_games; } 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; }