#include <bits/stdc++.h>
using namespace std;
#ifdef _LOCAL
#define debug(x) cerr << __LINE__ << ' ' << __PRETTY_FUNCTION__ << ": " << x << '\n';
#else
#define debug(...) 238;
#endif
mt19937 rng(238);
mt19937_64 rng64(238);
using ll = long long;
template <typename T, int U>
using ar = array<T, U>;
template <typename T, typename U>
bool chmin(T& x, const U&& y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T, typename U>
bool chmax(T& x, const U&& y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

#include <ext/pb_ds/assoc_container.hpp>
template <typename T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type,
                                     less<T>,
                                     __gnu_pbds::rb_tree_tag,
                                     __gnu_pbds::tree_order_statistics_node_update>; 

constexpr int Inf = 0x3f3f3f3f;
constexpr ll  inf = 0x3f3f3f3f3f3f3f3f;

void solve() {
    int n, m, t;
    cin >> n >> m >> t;
    vector<ll> a(n + 2, Inf);
    vector<ll> pref(n + 3);
    pref[0] = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    partial_sum(a.begin(), a.end(), next(pref.begin()));

    vector<int> b(m + 2);
    for (int i = 1; i <= m; ++i) {
        cin >> b[i];
    }    
    b[0] = 0;
    b[m + 1] = n + 1;

    ll ans = 0;
    int j = 0;
    for (int i = 1; i <= n; ++i) {
        if (b[j + 1] <= i) {
            j++;
        }

        {
            ll dist = pref[i] - pref[b[j]];
            ll rep = (t - dist) / a[i];
            if (dist <= t) {
                ans = max(ans, rep + i - b[j]);
            }
        }

        {
            ll dist = pref[b[j + 1] + 1] - pref[i + 1];
            ll rep = (t - dist) / a[i];
            if (dist <= t) {
                ans = max(ans, rep + b[j + 1] - i);
            }
        }
    }


    int lx = 0, rx = n + 1;
    while (lx + 1 < rx) {
        int mx = (lx + rx) >> 1;
        bool ok = false;
        for (int i = max(2, mx); i <= n + 1; ++i) {
            if ((binary_search(b.begin(), b.end(), i - 1) ||
                 binary_search(b.begin(), b.end(), i - mx)) &&
                pref[i] - pref[i - mx] <= t) {
                ok = true;
            }
        }
        if (ok) {
            lx = mx;
        } else {
            rx = mx;
        }
    }

    cout << max<ll>(lx, ans);
}

int main() {
#ifdef _LOCAL
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    cin.tie(0)->sync_with_stdio(0);

    int Tc = 1;
    // cin >> Tc;
    while (Tc--) {
        solve();
        cout << '\n';
    }

    return 0;
}