#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, T; cin >> n >> m >> T;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; ++i) cin >> a[i];
    vector<int> b(m + 1);
    for (int i = 1; i <= m; ++i) cin >> b[i];
    int ans = 0;
    auto solve = [&]() {
        vector<bool> in(n +1);
        for (int i = 1; i <= m; ++i) in[b[i]] = true;
        vector<pair<int, int>> q; //val,pos
        vector<int> pref(n + 1);
        for (int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + a[i];
        for (int i = 1; i <= n; ++i) {
            while (!q.empty() && q.back().first >= a[i]) q.pop_back();
            q.push_back({a[i], i});
            if (in[i]) {
                int z = 0;
                for (auto [val, pos] : q) {
                    z++;
                    if (z > 300) break;
                    int rem = T - (pref[i] - pref[pos - 1]);
                    if (rem < 0) break;
                    if (rem > 0) {
                        ans = max(ans, i - pos + 1 + rem / val);
                    }
                }
                z = 0;
                for (int j = q.size() - 1; j >= 0; --j) {
                    auto [val, pos] = q[j];
                    z++;
                    if (z > 300) break;
                    int rem = T - (pref[i] - pref[pos - 1]);
                    if (rem < 0) break;
                    if (rem > 0) {
                        ans = max(ans, i - pos + 1 + rem / val);
                    }
                }
            }
        }
        return;
    };
    solve();
    reverse(a.begin() + 1, a.end());
    for (int i = 1; i <= m; ++i) b[i] = n - b[i] + 1;
    solve();
    cout << ans;
    return 0;
}
