#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

using ll = long long;

struct segtree {
    vector <ll> t;
    ll size;
    void init(ll n) {
        size = 1;
        while (size < n)
            size *= 2;
        t.resize(size * 2 - 1);
    }

    ll merge(ll a, ll b) {
        return max(a, b);
    }

    void set(ll v, ll x, ll i, ll l, ll r) {
        if (r - l == 1) {
            t[v] = x;
            return;
        }
        ll m = (l + r) / 2;
        if (i < m)
            set(v * 2 + 1, x, i, l, m);
        else
            set(v * 2 + 2, x, i, m, r);
        t[v] = merge(t[v * 2 + 1], t[v * 2 + 2]);
    }
    void set(ll x, ll i) {
        set(0, x, i, 0, size);
    }

    ll get(ll v, ll tl, ll tr, ll ql, ll qr) {
        if (tr <= ql || tl >= qr) {
            return 0;
        }
        if (tl >= ql && tr <= qr) {
            return t[v];
        }
        ll tm = (tl + tr) / 2;
        return merge(get(v * 2 + 1, tl, tm, ql, qr), get(v * 2 + 2, tm, tr, ql, qr));
    }
    ll get(ll l, ll r) {
        return get(0, 0, size, l, r);
    }
};

/*vector <vector <ll>> gr, gr1;
vector <ll> t, comp;
vector <bool> used;

void dfs1(ll v) {
    used[v] = true;
    for (auto u : gr[v]) {
        if (!used[u]) {
            dfs1(u);
        }
    }
    t.emplace_back(v);
}

ll cur = 0;

void dfs2(ll v) {
    used[v] = true;
    comp[v] = cur;
    for (auto u : gr1[v]) {
        if (!used[u]) {
            dfs2(u);
        }
    }
}

void solve() {
    ll n, m;
    cin >> n >> m;
    gr.resize(n), used.resize(n), gr1.resize(n), comp.resize(n);
    for (int i = 0; i < m; ++i) {
        ll v, u;
        cin >> v >> u;
        v--; u--;
        gr[v].emplace_back(u);
        gr1[u].emplace_back(v);
    }
    for (int i = 0; i < n; ++i) {

    }
}*/

void solve1() {
    ll n, m, t;
    cin >> n >> m >> t;
    vector <ll> a(n), b(m);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }
    vector <ll> pref(n + 1);
    for (int i = 0; i < n; ++i) {
        pref[i + 1] = pref[i] + a[i];
    }
    vector <ll> mx(n);
    for (int i = 0; i < n; ++i) {
        ll l = 0, r = i + 2;
        if (a[i] > t) {
            continue;
        }
        while (r - l > 1) {
            ll mid = (l + r) / 2;
            if (pref[i + 1] - pref[i - mid + 1] > t)
                r = mid;
            else
                l = mid;
        }
        mx[i] = l;
    }
    ll ans = 0;
    for (int i = 0; i < m; ++i) {
        ans = max(ans, mx[b[i] - 1]);
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll tt = 1;
    //cin >> tt;
    while (tt--) {
        solve1();
        cout << endl;
    }
}
