#include using namespace std; int howManyGames(int p, int d, int m, int s) { // Return the number of games you can buy int c=0,k=0; while(k<=s&&p>=m){ k=k+p; p=p-d; c++; } if(k==s) return c; if(k>s) return c-1; while(k<=s){ k=k+m; c++; } if(k==s) return c; if(k>s) return c-1; return 0; } 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; }