#include <bits/stdc++.h>

using namespace std;
#define int long long
#define F first
#define S second

vector<int> f(const vector<int> &a, int t) {
    int n = (int) a.size();
    vector<int> ans(n), dp(n);
    ans[0] = t / a[0];
    for (int i = 1; i < n; ++i) {
        int sum = 0;
        for (int j = i; j >= dp[i - 1]; j--) {
            int x = (t - sum) / a[j];
            if (i - j + x > ans[i]) {
                ans[i] = i - j + x;
                dp[i] = j;
            }
            sum += a[j];
        }
    }
    return ans;
}

void solve() {
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(n), b(m);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
        --b[i];
    }
    vector<int> ans1 = f(a, t);
    std::reverse(a.begin(), a.end());
    vector<int> ans2 = f(a, t);
    std::reverse(ans2.begin(), ans2.end());
    int mx = 0;
    for (auto i: b) {
        mx = max(mx, max(ans1[i], ans2[i]));
    }
    cout << mx << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
