#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;

template<typename T>
istream& operator>>(istream& in, vector<T>& v);
template<typename T>
ostream& operator<<(ostream& out, vector<T>& v);
template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p);
template<typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& p);

template<typename T>
istream& operator>>(istream& in, vector<T>& v) {
    for (T& x : v) in >> x;
    return in;
}

template<typename T>
ostream& operator<<(ostream& out, vector<T>& v) {
    for (T& x : v) out << x << " ";
    return out;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
    in >> p.first >> p.second;
    return in;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& p) {
    out << p.first << " " << p.second;
    return out;
}

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
using ld = long double;

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define int long long

void solve() {
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(n), b(m);
    cin >> a >> b;
    for (int& x : b) x--;

    vector<ll> pref(n);
    for (int i = 0; i < n; i++) {
        pref[i] = a[i];
        if (i > 0) pref[i] += pref[i - 1];
    }

    int ans = 0, ptr = 0;
    for (int i = 0; i < n; i++) {
        while (ptr + 1 < m && b[ptr + 1] <= i) ptr++;
        auto check = [&](int j) {
            ll d;
            if (b[j] <= i) {
                d = pref[i] - (b[j] == 0 ? 0 : pref[b[j] - 1]);
            } else {
                d = pref[b[j]] - (i == 0 ? 0 : pref[i - 1]);
            }
            if (d <= t) {
                ans = max((ll)ans, abs(i - b[j]) + 1 + (t - d) / a[i]);
            }
        };
        check(ptr);
        if (ptr + 1 < m) check(ptr + 1);
    }
    cout << ans;
}

signed main() {
#ifndef LOCAL
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
#endif

    int t = 1;
//    cin >> t;
    while (t--) solve();
}