#include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define FAST_IO \ ios::sync_with_stdio(false); \ cin.tie(0); const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; int main() { FAST_IO auto ans = 0LL; vector> a(4); for (auto& [x, y] : a) cin >> x; for (auto& [x, y] : a) cin >> y; ranges::sort(a, [](auto& x, auto& y) { return x.second < y.second; }); i64 T; cin >> T; for (int i = 0; i < 4; i ++) { i64 x = min(a[i].first, T / a[i].second); ans += x; T -= x * a[i].second; } cout << ans << endl; }