#include using namespace std; int howManyGames(int p, int d, int m, int s) { // Return the number of games you can buy if (s < p) return 0; int count = 0; while (s > 0) { if (p == m) { if (s-p < 0) break; s-=p; count++; cerr << "s:" << s << std::endl; } if (p - d < m) { s-=p; int discout = p - m; p -= discout; cerr << "pdiscount:" << p << std::endl; cerr << "s:" << s << std::endl; count++; } else { s-=p; p-=d; cerr << "p" << p << std::endl; cerr << "s:" << s << std::endl; count++; } } if (s < 0) 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; }