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

#define all(x) x.begin(), x.end()
#define ff first
#define ss second

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using pii = pair<int, int>;

signed main() {
    // freopen("inputb.txt", "r", stdin);
    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];
        --b[i];
    }
    ll ans = 0;
    ll prev = -1;
    for (ll i = 0; i < m; ++i) {
        ll cur = 0;
        for (ll j = prev + 1; j < n; ++j) {
            ll time = 0;
            for (ll k = min(b[i], j); k <= max(b[i], j); ++k) {
                time += a[k];
            }
            if (time > t) {
                continue;
            }
            ll cand = abs(b[i] - j) + 1;
            cand += (t - time) / a[j];
            cur = max(cur, cand);
        }
        ans = max(ans, cur);
        prev = b[i];
    }
    cout << ans;
}
