#include using namespace std; int howManyGames(int p, int d, int m, int s) { // Return the number of games you can buy int count = -1; vector costs; costs.push_back(p); int init = p - d; while(init >= m){ costs.push_back(init); init = init - d; } int money = s; int flag = 0; for(int i = 0 ; i < costs.size() ; i++) { if( money >= 0 ) { money = money - costs[i]; count++; } else{ flag = 1; break; } } if(flag == 1) return count; while(money >= 0) { money = money - m; count++; } return count; } 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; }