#include using namespace std; int howManyGames(int p, int d, int m, int s) { int r=0,x=0; int count=0; while(1) { r+=p; if(x==0) p=p-d; if(p<=m){ x=1; p=m; } if(r<=s) count++; else return count; } // Return the number of games you can buy } int main() { int p; int d; int m; int s; cin >> p >> d >> m >> s; int answer = howManyGames(p, d, m, s); cout << answer << endl; return 0; }