#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { ll B, T, F, P; }; unsigned MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int UNKO = INT_MAX; int dp[11][101][10001]; int main() { int a4, a3, a1; cin >> a4 >> a3 >> a1; int Db; cin >> Db; int b4, b3, b1; cin >> b4 >> b3 >> b1; int Dc; cin >> Dc; int c4, c3, c1; cin >> c4 >> c3 >> c1; for (int i = 0; i <= 10; i++) for (int j = 0; j <= 100; j++) for (int k = 0; k <= 10000; k++) { int& x = dp[i][j][k]; int _Db = Db; int B4 = min(i, _Db / 1000); _Db -= B4 * 1000; int B3 = min(j, _Db / 100); _Db -= B3 * 100; int B1 = min(k, _Db / 1); _Db -= B1 * 1; if (!_Db) x = max(x, dp[i - B4 + b4][j - B3 + b3][k - B1 + b1] + 1); int _Dc = Dc; int C4 = min(i, _Dc / 1000); _Dc -= C4 * 1000; int C3 = min(j, _Dc / 100); _Dc -= C3 * 100; int C1 = min(k, _Dc / 1); _Dc -= C1 * 1; if (!_Dc) x = max(x, dp[i - C4 + c4][j - C3 + c3][k - C1 + c1] + 1); } cout << dp[a4][a3][a1] << endl; }