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

using ll = long long;

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>;

vector<ll> p;

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

inline void solve() {
    /*ordered_set<ll> s;
    cout << (*s.find_by_order(2)) << endl;
    cout << s.order_of_key(2) << endl;*/
    ll n, m, t;
    cin >> n >> m >> t;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<ll> b(m);
    for (ll i = 0; i < m; i++) {
        cin >> b[i];
        b[i]--;
    }
    ll ans = 0;
    p.resize(n + 1, 0);
    for (ll i = 1; i < n + 1; i++) {
        p[i] = p[i - 1] + a[i - 1];
    }
ll i = 0;
for (ll j = 0; j < n; j++) {
if (a[j] < a[i]) {
i = j;
}
}
    {
        if (a[i] > t) {
            continue;
        }
        for (ll j = 0; j < n; j++) {
            ll tans = 0;
            if (j <= i) {
                ll l = j - 1, r = i;
                while (r - l > 1) {
                    ll d = (r + l) / 2;
                    if (get(d + 1, i) <= t) {
                        r = d;
                    } else {
                        l = d;
                    }
                }
                tans = i - r;
                if (r == j) {
                    tans += (t - get(r + 1, i)) / a[r];
                }
            } else {
                ll l = i, r = j + 1;
                while (r - l > 1) {
                    ll d = (r + l) / 2;
                    if (get(i, d - 1) <= t) {
                        l = d;
                    } else {
                        r = d;
                    }
                }
                tans = l - i;
                if (l == j) {
                    tans += (t - get(i, l - 1)) / a[l];
                }
            }
            ans = max(ans, tans);
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    ll q = 1;
    // cin >> q;
    while (q--) {
        solve();
    }
}
