#include using namespace std; using Int = long long; template inline bool setmin(T &A, T B){ if (A > B){ A = B; return true; } else { return false; } } template inline bool setmax(T &A, T B){ if (A < B){ A = B; return true; } else { return false; } } #define REP(x, y) for (int x = 0; x < int(y); ++x) #define rep(x, y, z) for (int x = int(y); x < int(z); ++x) #define PER(x, y) for (int x = int(y) - 1; x >= 0; --x) #define per(x, y, z) for (int x = int(z) - 1; x >= int(y); --x) void solve(){ Int A, B, C, D; cin >> A >> B >> C >> D; Int P, Q, R, S, T; cin >> P >> Q >> R >> S >> T; vector> X; X.push_back({P, A}); X.push_back({Q, B}); X.push_back({R, C}); X.push_back({S, D}); sort(X.begin(), X.end()); Int ans = 0; REP(i, X.size()){ if (X[i].first * X[i].second <= T){ T -= X[i].first * X[i].second; ans += X[i].second; } else { ans += T / X[i].first; T = 0; } } cout << ans << '\n'; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; while (t--){ solve(); } }