#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 +123;

using ll = long long;

mt19937_64 rng (time (0));

#define int long long
int n, m, T;
int a[N], b[N], pref[N];
int get (int ps) {
    int cur = 0;
    for (int i = 1; i <= n; ++i) {
        int le = i, ri = ps;
        if (le > ri) {
            swap (le, ri);
        }
        int cnt = pref[ri] - pref[le - 1];
        if (cnt <= T) {
            cur = max (cur, (ri - le + 1) + (T - cnt) / a[i]);
        }
    }
    return cur;
}
void solve () {
    cin >> n >> m >> T;
    for (int i = 1; i <= n; ++i) cin >> a[i], pref[i] = pref[i - 1] + a[i];
    for (int i = 1; i <= m; ++i) cin >> b[i];
    int ans = 0;
    for (int i = 1; i <= m; ++i) {
        ans = max (ans, get (b[i]));
    }
    cout << ans << '\n';
}
signed main() {
#ifdef local
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // local
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int test = 1;
    while (test--) solve();
}
