#include "bits/extc++.h"

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

template<typename T>
istream &operator>>(istream &is, vector<T> &a);

template<typename T>
ostream &operator<<(ostream &os, vector<T> &a);


using ordered_set = tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    ll n, m, T;
    cin >> n >> m >> T;

    vector<ll> a(n);
    vector<ll> b(m);
    cin >> a >> b;

    vector<ll> need(n);
    for (int i = 0; i < m; ++i) {
        need[b[i] - 1] = true;
    }


    vector<ll> ans(n);
    {
        vector<ll> pref(n + 1);
        for (int i = 0; i < n; ++i) {
            pref[i + 1] = pref[i] + a[i];
        }

        vector<ll> q;
        for (int i = 0; i < n; ++i) {
            while (!q.empty() && a[q.back()] >= a[i]) {
                q.pop_back();
            }
            q.push_back(i);

            if (!need[i]) continue;
            for (int ind = q.size() - 1; ind >= 0; --ind) {
                int l = q[ind];
                ll ost = T - (pref[i + 1] - pref[l]);
                if (ost < 0) break;

                ans[i] = max(ans[i], (i-l+1) + ost / a[l]);
            }
        }
    }
    {
        std::reverse(a.begin(), a.end());

        vector<ll> pref(n + 1);
        for (int i = 0; i < n; ++i) {
            pref[i + 1] = pref[i] + a[i];
        }

        vector<ll> q;
        for (int i = 0; i < n; ++i) {
            while (!q.empty() && a[q.back()] >= a[i]) {
                q.pop_back();
            }
            q.push_back(i);

            if (!need[n - i - 1]) continue;
            for (int ind = q.size() - 1; ind >= 0; --ind) {
                int l = q[ind];
                ll ost = T - (pref[i + 1] - pref[l]);
                if (ost < 0) break;

                ans[n - i - 1] = max(ans[n - i - 1], (i-l+1) + ost / a[l]);
            }
        }
    }

    ll res = 0;
    for (int i = 0; i < m; ++i) {
        res = max(res, ans[b[i] - 1]);
    }
    cout << res << "\n";
}

template<typename T>
istream &operator>>(istream &is, vector<T> &a) {
    for (auto &v: a) is >> v;
    return is;
}

template<typename T>
ostream &operator<<(ostream &os, vector<T> &a) {
    for (auto v: a) os << v << " ";
    return (os << "\n");
}