#include using namespace std; using ll = long long; template istream& operator >> (istream& is, vector& vec) { for(T& x : vec) is >> x; return is; } template ostream& operator << (ostream& os, const vector& vec) { if(vec.empty()) return os; os << vec[0]; for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it; return os; } int main(){ ios::sync_with_stdio(false); cin.tie(0); ll t; vector> a(4); for(auto &&[x, y] : a) cin >> y; for(auto &&[x, y] : a) cin >> x; cin >> t; ll ans = 0; sort(a.begin(), a.end()); for(auto [x, y] : a){ ll d = min(y, t / x); t -= x * d; ans += d; } cout << ans << '\n'; }