#include using namespace std; int kDebt[2], e1000[2], e100[2], e1[2]; int dp[11][101][10001]; int solve(int const kA1000, int const kA100, int const kA1) { int& ret = dp[kA1000][kA100][kA1]; if(ret >= 0) return ret; ret = 0; for(int i=0;i<2;i++) { int a1000 = kA1000, a100 = kA1000, a1 = kA1; int debt = kDebt[i]; while(a1000 > 0 && debt >= 1000) { a1000--, debt-=1000; } while(a100 > 0 && debt >= 100) { a100--, debt-=100; } if(a1 >= debt) { a1 -= debt, debt = 0; } if(debt == 0) { ret = max(ret, 1+solve(a1000+e1000[i], a100+e100[i], a1+e1[i])); } } return ret; } int main() { int a1000, a100, a1; cin >> a1000 >> a100 >> a1; for(int i=0;i<2;i++) cin >> kDebt[i] >> e1000[i] >> e100[i] >> e1[i]; cout << solve(a1000, a100, a1) << endl; return 0; }