#include <bits/stdc++.h>
#define int long long
#define double long double

using namespace std;

int solve(int n, int m, int t, vector<int> a, vector<int> b) {
    vector<int> pref(n);
    pref[0] = a[0];
    for (int i = 1; i < n; i++) {
        pref[i] = pref[i - 1] + a[i];
    }
    set<pair<double, int>> prefdp;
    vector<int> dp(n);
    for (int i = 0; i < n; i++) {
        prefdp.insert({-i + (double)pref[i] / (double)a[i], i});
        while (prefdp.size() && pref[i] - pref[prev(prefdp.end())->second] > t) {
            prefdp.erase(prev(prefdp.end()));
        }
        auto it = prev(prefdp.end());
        int cnt = 20;
        while (cnt > 0) {
            int j = it->second;
            if (pref[i] - pref[j] <= t) {
                dp[i] = max(dp[i], i - j + (t - pref[i] + pref[j]) / a[j]);
            }
            if (it == prefdp.begin()) {
                break;
            }
            it--;
            cnt--;
        }
    }
    // for (int i : dp) cout << i << " ";
    // cout << "\n";
    // for (int i : b) cout << i << " ";
    // cout << "\n";
    int ans = 0;
    for (int i : b) {
        ans = max(ans, dp[i]);
    }
    return ans;
}

signed main() {
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(n), b(m);
    for (auto& i : a) {
        signed x;
        cin >> x;
        i = x;
    }
    for (auto& i : b) {
        signed x;
        cin >> x;
        i = x;
        i--;
    }
    int ans = solve(n, m, t, a, b);
    reverse(a.begin(), a.end());
    for (int& i : b) {
        i = n - i - 1;
    }
    ans = max(ans, solve(n, m, t, a, b));
    cout << ans << "\n";
}