#include #include #include #include #include #include #include int howManyGames(int p, int d, int m, int s) { // Return the number of games you can buy int wallet=0,ans=0,i,game[11]={20,17,14,11,8,6,6,6,6,6,6}; wallet=s; for(i=0;i<11;i++) if(game[i]<=wallet) { wallet=wallet-game[i]; ans++; } return ans; } 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; }