#include "bits/stdc++.h" using namespace std; int A[3], B[3], C[3]; int now[3]; int DB, DC; bool useB(){ int nokori = DB; int use0 = min(now[0], nokori / 1000); nokori -= use0 * 1000; int use1 = min(now[1], nokori / 100); nokori -= use1 * 100; int use2 = min(now[2], nokori / 1); nokori -= use2 * 1; if (nokori != 0) return false; now[0] += B[0] - use0; now[1] += B[1] - use1; now[2] += B[2] - use2; } bool useC(){ int nokori = DC; int use0 = min(now[0], nokori / 1000); nokori -= use0 * 1000; int use1 = min(now[1], nokori / 100); nokori -= use1 * 100; int use2 = min(now[2], nokori / 1); nokori -= use2 * 1; if (nokori != 0) return false; now[0] += C[0] - use0; now[1] += C[1] - use1; now[2] += C[2] - use2; } int main() { cin >> A[0] >> A[1] >> A[2]; cin >> DB; cin >> B[0] >> B[1] >> B[2]; cin >> DC; cin >> C[0] >> C[1] >> C[2]; int ans = 0; for (int i = 0; i <= 10000; i++) { for (int j = 0; j < 3; j++) { now[j] = A[j]; } int nokori = i; int count = 0; while (1){ if (nokori > 0 && useB()){ count++; nokori--; } else if (useC()) count++; else break; } ans = max(ans, count); } for (int i = 0; i <= 10000; i++) { for (int j = 0; j < 3; j++) { now[j] = A[j]; } int nokori = i; int count = 0; while (1){ if (nokori > 0 && useC()){ count++; nokori--; } else if (useB()) count++; else break; } ans = max(ans, count); } cout << ans << endl; }