#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>

#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define int long long

// #pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

using oset = tree<pll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>; 

constexpr ll inf = 1e18;

void solve() {
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(n);
    vector<ll> p(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        p[i + 1] = p[i] + a[i];
    }
    vector<int> b(m);
    for (int &e : b) {
        cin >> e;
        e--;
    }

    int s = 0;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        while (s != m and b[s] <= i) s++;
        if (s != m) {
            if (p[b[s]] - p[i] <= t) {
                ans = max(ans, (t - (p[b[s] + 1] - p[i + 1])) / a[i] + b[s] - i);
            }
        }
        if (s != 0) {
            if (p[i] - p[b[s - 1]] <= t) {
                ans = max(ans, (t - (p[i] - p[b[s - 1]])) / a[i] + i - b[s - 1]);
            }
        }
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}