#include <bits/stdc++.h>
using namespace std;

using ll = long long;

long long findMaximumAlloyUnits(vector<int> composition,
                               vector<int> stock,
                               vector<int> cost,
                               int budget) {

    int n = composition.size();

    ll low = 0, high = 1000000000LL;
    ll ans = 0;

    while (low <= high) {
        ll mid = low + (high - low) / 2;

        ll sum = 0;

        for (int i = 0; i < n; i++) {

            ll need = 1LL * composition[i] * mid;
            ll extra = max(0LL, need - stock[i]);

            sum += extra * cost[i];

            if (sum > budget)
                break;
        }

        if (sum <= budget) {
            ans = mid;
            low = mid + 1;
        } else {
            high = mid - 1;
        }
    }

    return ans;
}

int main() {

    int n;
    cin >> n;

    vector<int> composition(n), stock(n), cost(n);

    for (int i = 0; i < n; i++)
        cin >> composition[i];

    for (int i = 0; i < n; i++)
        cin >> stock[i];

    for (int i = 0; i < n; i++)
        cin >> cost[i];

    int budget;
    cin >> budget;

    cout << findMaximumAlloyUnits(composition, stock, cost, budget);

    return 0;
}