// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")

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

// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#ifdef LOCAL
    #define debug(x) cout << #x << ": " << x << endl;
#else
    #define debug(x)
#endif
#define mt_seed chrono::high_resolution_clock::now().time_since_epoch().count()
#define time_now chrono::high_resolution_clock::now()
#define time_res(s, f) chrono::duration_cast<chrono::nanoseconds>(f - s).count()
#define time_out(s) cout << fixed << setprecision(10) << endl << "Used: " << (ld)time_res(s, time_now) / 1e6 << " ms" << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define file_in freopen("input.txt", "r", stdin);
#define file_out freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define pb push_back
#define ff first
#define sc second
#define int ll

using namespace std;
using namespace __gnu_pbds;

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using str = string;
using pii = pair<int, int>;
using ordered_set = tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T1, typename T2> istream& operator>>(istream &in, pair<T1, T2> &a) { in >> a.ff >> a.sc; return in; }
#ifdef LOCAL
    template<typename T1, typename T2> ostream& operator<<(ostream &out, const pair<T1, T2> &a) { out << "{" << a.ff << ' ' << a.sc << "}"; return out; }
#else
    template<typename T1, typename T2> ostream& operator<<(ostream &out, const pair<T1, T2> &a) { out << a.ff << ' ' << a.sc; return out; }
#endif
template<typename T> istream& operator>>(istream &in, vector<T> &a) { for (auto &el : a) in >> el; return in; }
template<typename T> ostream& operator<<(ostream &out, const vector<T> &a) { for (auto &el : a) out << el << " "; return out; }
template<typename T> ostream& operator<<(ostream &out, const set<T> &a) { for (auto &el : a) out << el << " "; return out; }
template<typename T> ostream& operator<<(ostream &out, const multiset<T> &a) { for (auto &el : a) out << el << " "; return out; }
template<typename T, typename comp> ostream& operator<<(ostream &out, const unordered_set<T, comp> &a) { for (auto &el : a) out << el << " "; return out; }
template<typename T> T max(T a, T b, T c) { return max(a, max(b, c)); }
template<typename T> T max(T a, T b, T c, T d) { return max(max(a, b), max(c, d)); }
template<typename T> T min(T a, T b, T c) { return min(a, min(b, c)); }
template<typename T> T min(T a, T b, T c, T d) { return min(min(a, b), min(c, d)); }
const ll LOL = mt_seed;
mt19937_64 genom(LOL); ll randint(ll l, ll r) { uniform_int_distribution<ll> random_distrib_2_0(l, r); return random_distrib_2_0(genom); }
const ll RANDOM = genom(); struct chash { ll operator()(ll x) { return x ^ RANDOM; } };

signed main() {
    fast
#ifdef LOCAL
    file_in
#endif

    int n, m, T;
    cin >> n >> m >> T;
    vector<int> a(n), b(m);
    cin >> a >> b;
    
    for (auto &el : b) --el;

    vector<int> pref(n + 1);
    for (int i = 0; i < n; ++i)
        pref[i + 1] = pref[i] + a[i];

    int ans = 0;
    for (int i = 0; i < m; ++i) {
        for (int j = (i == 0 ? 0 : b[i - 1]); j <= b[i]; ++j) {
            if (pref[b[i] + 1] - pref[j + 1] > T) continue;
            int cur = b[i] - j;
            cur += (T - (pref[b[i] + 1] - pref[j + 1])) / a[j];
            ans = max(ans, cur);
            // cout << i << " " << j << ": " << cur << endl;
        }
        for (int j = b[i]; j <= (i == m - 1 ? n - 1 : b[i + 1]); ++j) {
            if (pref[j] - pref[b[i]] > T) continue;
            int cur = j - b[i];
            cur += (T - (pref[j] - pref[b[i]])) / a[j];
            ans = max(ans, cur);
            // cout << i << " " << j << ": " << cur << endl;
        }
        // debug(ans)
    }
    cout << ans << '\n';

    return 0;
}
