#include #include #include using namespace std; using ll = long long; int main() { ll A, B, C, D; cin >> A >> B >> C >> D; ll P, Q, R, S, T; cin >> P >> Q >> R >> S >> T; vector> p(4); p[0] = make_pair(P, A); p[1] = make_pair(Q, B); p[2] = make_pair(R, C); p[3] = make_pair(S, D); sort(p.begin(), p.end()); ll rem = T; ll ans = 0; for (ll i = 0; i < 4; i++) { if (p[i].first * p[i].second <= rem) { rem -= p[i].first * p[i].second; ans += p[i].second; } else { ans += rem / p[i].first; break; } } cout << ans << endl; }