//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2")
#define _GLIBCXX_DEBUG 1
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define forsn(i,s,e) for(ll i = s; i <= e; i++)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln '\n'
#define all(x) x.begin(), x.end()

const ll inf = 1e9 + 1;

vector <ll> pref;

ll get_sum(ll l, ll r) {
    if (l > r)
        return 0;
    if (l == 0)
        return pref[r];
    return pref[r] - pref[l - 1];
}

ll n, m, T;
vector <ll> b;

ll get_ans(vector <ll>& a) {pref.resize(n);
    pref.clear();
    pref.resize(n);
    pref[0] = a[0];
    forsn(i, 1, n - 1) {
        pref[i] = pref[i - 1] + a[i];
    }
    vector <ll> dp(n);
    dp[0] = 1;
    ll s = 0;
    forsn(i, 1, n - 1) {
        if (a[i] >= a[i - 1]) {
            dp[i] = dp[i - 1] + 1;
            s += a[i + 2 - dp[i]];
        } else {
            dp[i] = 1;
            s = 0;
        }
        while (dp[i] > 1 && s > T) {
            s -= a[i - dp[i] + 2];
            dp[i]--;
        }
    }
    ll ans = 0;
    forsn(idx, 0, m - 1) {
        ll i = b[idx] - 1;
        ll j = i - dp[i] + 1;
        ll t = get_sum(j + 1, i);
        ll cnt = i - j;
        ll res = cnt + (T - t) / a[j];
        ans = max(ans, res);
    }

    return ans;
}

ll solve2(vector <ll>& a) {
    pref.clear();
    pref.resize(n);
    pref[0] = a[0];
    forsn(i, 1, n - 1) {
        pref[i] = pref[i - 1] + a[i];
    }

    ll ans = 0;
    forsn(idx, 0, m - 1) {
        ll i = b[idx] - 1;
        ll l = 0, r = i;
        while (l < r - 1) {
            ll mid = (l + r) / 2;
            ll s = get_sum(mid + 1, i);
            if (s > T)
                l = mid;
            else
                r = mid;
        }
        ll s = get_sum(l + 1, i);
        ll cur = r;
        if (s <= T)
            cur = l;
        ll t = get_sum(cur + 1, i);
        ll cnt = i - cur;
        ll res = cnt + (T - t) / a[cur];
        ans = max(ans, res);
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    cin >> n >> m >> T;
    vector <ll> a(n);
    bool flag = true;
    forsn(i, 0, n - 1) {
        cin >> a[i];
        if (i > 0 && a[i] < a[i - 1])
            flag = false;
    }
    b.resize(n);
    for (ll& i: b)
        cin >> i;

    if (flag) {
        ll ans = solve2(a);
        cout << ans;
        exit(0);
    }

    ll ans1 = get_ans(a);
    reverse(all(a));
    forsn(i, 0, m - 1) {
        b[i] = n - b[i] + 1;
    }
    ll ans2 = get_ans(a);
    ll ans = max(ans1, ans2);

    cout << ans;

    return 0;
}
