#include #include #include #include #include #include #include int howManyGames(int p, int d, int m, int s) { // printf("%d",s); int count=0; while(s>=0){ // printf("%d",s); if(count==0&&s>=p) { // printf("%d",s); count++; // printf("dd"); s=s-p; if(p-d>=m) p=p-d; else p=m; } else if(count>0&&s>=p){ count++; s=s-p; if(p-d>=m) p=p-d; else p=m; } else return count; } return count; // Return the number of games you can buy } 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; }