//  #define LOCAL
//#define SUKA
#ifdef SUKA
#pragma GCC optimize("O3")
#define GCC optimize("unroll-loops")
#endif
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << x << "\n";
#else
#define debug(x)
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using oset = tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

struct segtree {
    vector<ll> t;

    segtree(const vector<ll>& a) {
        t.resize(a.size()*4);
        build(1, 0, a.size(), a);
    }

    void build (ll v, ll tl, ll tr, const vector<ll>& a) {
        if (tr - tl == 1) {
            t[v] = a[tl];
            return;
        }
        ll tm = (tl + tr) / 2;
        build(v*2, tl, tm, a);
        build(v*2+1, tm, tr, a);
        t[v] = t[v*2] + t[v*2+1];
    }

    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 get(v*2, tl, tm, ql, qr) + get(v*2+1, tm, tr, ql, qr);
    }

    void update(ll v, ll tl, ll tr, ll pos, ll x) {
        if (tr - tl == 1) {
            t[v] = x;
        }
        ll tm = (tl + tr) / 2;
        if (pos > tm) {
            update(v*2, tl, tm, pos, x);
        }
        else {
            update(v*2+1, tm, tr, pos, x);
        }
        t[v] = t[v*2] + t[v*2+1];
    }
};

void solve() {
    ll n, m, t;
    cin >> n >> m >> t;
    vector<ll> a(n), b(m), psa(n+1), ansq(n);
    for (ll i = 0;i<n;i++) {
        cin >> a[i];
        psa[i+1] = a[i] + psa[i];
    }
    for (ll i =0; i < m;i++) {
        cin >> b[i];
    }
    ll ans = 0, rest = 0;
    {
        vector<ll> vans(n), vrest(n);
        ll lg = -1;
        for (ll i = 0;i < n;i++) {
            ll res1 = 0, sum1 = 0, rest1 = 0;
            bool f = true;
            for (ll j = i;j > lg;j--) {
                sum1 += a[j];
                if (sum1 > t){
                    f = false;
                    break;
                }
                res1 = max(res1, i - j + 1 + (t - sum1) / a[j]);
                if (res1 == i - j + 1 + (t - sum1) / a[j]) {
                    rest1 = max(rest1, (t - sum1) % a[j]);
                }
            }
            if (lg == -1 || !f) {
                vans[i] = res1;
                vrest[i] = rest1;
                continue;
            }
            if (sum1 > vrest[lg]) {
                //vans
            }
        }
    }
    ll ans2 = 0, rest2 = 0;
    {
        std::reverse(a.begin(), a.end());
        for (ll i = 0; i < n; i++) {
            ll res1 = t / a[i];
            ll rest1 = t % a[i];
            if (a[i] > rest2) {
                if (res1 > ans2) {
                    ans2 = res1;
                    rest2 = rest1;
                }
                continue;
            }
            if (res1 > ans2 + 1) {
                ans2 = res1;
                rest2 = rest1;
            } else if (ans2 + 1 > res1) {
                ans2++;
                rest2 -= a[i];
            } else {
                ans2++;
                rest2 = max(rest2 - a[i], rest1);
            }
        }
    }
    cout << max(ans, ans2);
}

void solve13() {
    ll n, m, t;
    cin >> n >> m >> t;
    vector<ll> a(n), b(m);
    for (ll i = 0;i<n;i++) {
        cin >> a[i];
    }
    for (ll i =0; i < m;i++) {
        cin >> b[i];
    }
    ll ans = 0;
    for (auto x : b) {
        --x;
        ll res = 0, sum = 0;
        for (ll i = x;i >= 0;i--) {
            sum += a[i];
            if (sum > t) break;
            res++;
            ans = max(ans, res + (t - sum) / a[i]);
        }
        res = 0, sum = 0;
        for (ll i = x;i < n;i++) {
            sum += a[i];
            if (sum > t) break;
            res++;
            ans = max(ans, res + (t - sum) / a[i]);
        }
    }
    cout << ans;
}

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

bool res(vector<ll> a, vector<ll> b, vector<ll> c){
    ll n = a.size(), m = b.size();
    if (n == 0) return false;
    ll idx = std::min_element(a.begin(), a.end()) - a.begin();
    if (idx >= m) {
        vector<ll> newa;
        for (ll i = 0;i<n;i++) {
            if (i != idx) newa.push_back(a[i]);
        }
        auto tp = res(newa, b, c);
        return !tp;
    }
    {
        vector<ll> newa, newb, newc;
        for (ll i = 0;i<n;i++) {
            if (i != idx) newa.push_back(a[i]);
            if (i != idx && i < m) {
                newb.push_back(b[i]);
                newc.push_back(c[i]);
            }
        }
        auto tp = res(newa, newb, newc);
        if (!tp) return true;
    }
    if (c[idx] == 1) {
        return false;
    }
    swap(a[idx], b[idx]);
    c[idx] = 1 - c[idx];
    auto tp = res(a,b,c);
    return !tp;
}

void solveGlass() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n), c(m);
    for (ll i = 0;i<n;i++) {
        cin >> a[i];
    }
    for (ll i =0 ;i<n;i++) {
        cin >> b[i];
    }
    for (ll i = 0;i<m;i++){
        ll w;
        cin >> w;
        a.push_back(w);
    }
    auto tp = res(a,b, vector<ll>(n));
    if (tp) cout << "First";
    else cout << "Second";
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll t = 1;
    //x`cin >> t;
    while (t--) {
        solve2();
        cout << "\n";
    }
    //cout << res({1,2,3},1);
}
