#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class Badgers { public:
	int feedMost(vector <int> hunger, vector <int> greed, int totalFood) 
	{
		for(int m=hunger.size(); m>0; --m)	
			if( can(m, hunger, greed, totalFood) )
				return m;
		return 0;
	}
	bool can(int m, vector<int> h, const vector<int>& g, int totalFood)
	{
		for(int i=0; i<h.size(); ++i)
			h[i] += g[i]*(m-1);
		sort(h.begin(), h.end());
		return accumulate(h.begin(), h.begin()+m, 0) <= totalFood;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, Badgers().feedMost(hunger, greed, totalFood));}
int main(){

CASE(0)
	int hunger_[] = {1,2,3};
	  vector <int> hunger(hunger_, hunger_+sizeof(hunger_)/sizeof(*hunger_)); 
	int greed_[] = {2,2,1};
	  vector <int> greed(greed_, greed_+sizeof(greed_)/sizeof(*greed_)); 
	int totalFood = 7; 
	int _ = 2; 
END
CASE(1)
	int hunger_[] = {5,2,1,5};
	  vector <int> hunger(hunger_, hunger_+sizeof(hunger_)/sizeof(*hunger_)); 
	int greed_[] = {0,2,4,1};
	  vector <int> greed(greed_, greed_+sizeof(greed_)/sizeof(*greed_)); 
	int totalFood = 19; 
	int _ = 3; 
END
CASE(2)
	int hunger_[] = {1,1,1,1,1};
	  vector <int> hunger(hunger_, hunger_+sizeof(hunger_)/sizeof(*hunger_)); 
	int greed_[] = {1000,1000,1000,1000,1000};
	  vector <int> greed(greed_, greed_+sizeof(greed_)/sizeof(*greed_)); 
	int totalFood = 10; 
	int _ = 1; 
END
CASE(3)
	int hunger_[] = {1,2,3,4,5,6,7,8,9,10};
	  vector <int> hunger(hunger_, hunger_+sizeof(hunger_)/sizeof(*hunger_)); 
	int greed_[] = {10,9,8,7,6,5,4,3,2,1};
	  vector <int> greed(greed_, greed_+sizeof(greed_)/sizeof(*greed_)); 
	int totalFood = 100; 
	int _ = 5; 
END
CASE(4)
	int hunger_[] = {2};
	  vector <int> hunger(hunger_, hunger_+sizeof(hunger_)/sizeof(*hunger_)); 
	  int greed_[] = {0};
	  vector <int> greed(greed_, greed_+sizeof(greed_)/sizeof(*greed_)); 
	  int totalFood = {1}; 
	  int _ = 0; 
END
CASE(4)
	int hunger_[] = {2};
	  vector <int> hunger(hunger_, hunger_+sizeof(hunger_)/sizeof(*hunger_)); 
	  int greed_[] = {0};
	  vector <int> greed(greed_, greed_+sizeof(greed_)/sizeof(*greed_)); 
	  int totalFood = {2}; 
	  int _ = 1; 
END
CASE(4)
	int hunger_[] = {2};
	  vector <int> hunger(hunger_, hunger_+sizeof(hunger_)/sizeof(*hunger_)); 
	  int greed_[] = {0};
	  vector <int> greed(greed_, greed_+sizeof(greed_)/sizeof(*greed_)); 
	  int totalFood = {1000000}; 
	  int _ = 1; 
END
CASE(5)
int hunger_[] = {1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10};
	  vector <int> hunger(hunger_, hunger_+sizeof(hunger_)/sizeof(*hunger_)); 
	  int greed_[] = {100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100};
	  vector <int> greed(greed_, greed_+sizeof(greed_)/sizeof(*greed_)); 
	int totalFood = 10000; 
	int _ = -1; 
END

}
// END CUT HERE
