#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

vector<ll> a, b, p;
ll n, m, t;

ll get(ll l, ll r) {
    if (!l) return p[r];
    return p[r] - p[l - 1];
};

ll calc(ll i, ll j) {
    if (i <= j) {
        ll d = get(i, j);
        if (d > t) return 0;
        ll left = t - d;
        ll add = left / a[j];
        return add + (j - i + 1);
    }
    else {
        ll d = get(j, i);
        if (d > t) return 0;
        ll left = t - d;
        ll add = left / a[j];
        return add + (i - j + 1);
    }
};

/*
 * 4 4 10
2 3 1 3
1 2 3 4
 */

void obla() {
    cin >> n >> m >> t;
    a.resize(n),  p.resize(n);
    b.resize(m);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) {
        cin >> b[i];
        b[i]--;
    }
    for (int i = 0; i < n; i++) {
        p[i] = a[i];
        if (i > 0) p[i] += p[i - 1];
    }
    ll ans = 0;
    for (auto pos : b) {
        for (int i = 0; i < n; i++) {
            ans = max(ans, calc(pos, i));
        }
    }
    cout << ans << '\n';
}

int main() {
    int t = 1; //cin >> t;
    cin.tie(0);
    ios::sync_with_stdio(0);
    while (t--) {
        obla();
    }
}
