#include #include #define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) using namespace atcoder; using namespace std; typedef long long ll; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); vector a(4), b(4); rep(i, 0, 4) cin >> a[i]; rep(i, 0, 4) cin >> b[i]; rep(i, 0, 4) rep(j, 0, 3) { if (b[j] > b[j + 1]) { swap(a[j], a[j + 1]); swap(b[j], b[j + 1]); } } ll t; cin >> t; ll ans = 0; rep(i, 0, 4) { ll add = min(t / b[i], a[i]); t -= add * b[i]; ans += add; } cout << ans << endl; }