#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi2")

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <typename T>
using ordered_set = __gnu_pbds::tree <T, __gnu_pbds::null_type, less <T>,
        __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template <typename T>
int sz(const T &x) {
    return static_cast <int> (x.size());
}

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

const int MAXN = 3e5;
const int INF = 2e9;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-8;

ll max_roads[MAXN];

struct Sparce_table {
    ll n;
    vector <ll> my_log;
    vector <vector <pair <ll, ll>>> table;
    Sparce_table(vector <ll>& a) {
        n = sz(a);
        my_log.assign(n + 1, 0);
        for (ll i = 2; i <= n; i++) {
            my_log[i] = my_log[i / 2] + 1;
        }
        table.assign(my_log[n] + 1, vector <pair <ll, ll>> (n));
        for (ll i = 0; i < n; i++) {
            table[0][i] = {a[i], i};
        }
        for (ll i = 1; i <= my_log[n]; i++) {
            for (ll j = 0; j + (1 << i) <= n; j++) {
                table[i][j] = min(table[i - 1][j], table[i - 1][j + (1 << (i - 1))]);
            }
        }
    }
    ll get(ll l, ll r) {
        ll degree = my_log[r - l];
        return min(table[degree][l], table[degree][r - (1 << degree)]).second;
    }
};

ll count_roads(ll start, ll farthest_end, ll t, vector <ll>& roads, vector <ll>& pref_sums, Sparce_table& table) {
    ll end = table.get(start, farthest_end + 1);
    if (t < pref_sums[farthest_end] - pref_sums[start]) {
        return 0;
    }
    return end - start + (t - (pref_sums[farthest_end] - pref_sums[start])) / roads[end];
}

void solve(ll n, ll m, ll t, vector <ll>& a, vector <ll>& b) {
    vector <ll> pref_sums(n + 1, 0);
    for (ll i = 1; i <= n; i++) {
        pref_sums[i] = pref_sums[i - 1] + a[i - 1];
    }
    Sparce_table table(a);
    for (ll i = 0; i < m; i++) {
        ll l = b[i], r = n - 1, x1, x2, y1, y2;
        while (r - l > 2) {
            x1 = (2 * l + r) / 3;
            x2 = (l + 2 * r) / 3;
            y1 = count_roads(b[i], x1, t, a, pref_sums, table);
            y2 = count_roads(b[i], x2, t, a, pref_sums, table);
            if (y1 < y2) {
                l = x1;
            } else {
                r = x2;
            }
        }
        max_roads[i] = max({max_roads[i],
                            count_roads(b[i], l, t, a, pref_sums, table),
                            count_roads(b[i], min(l + 1, r), t, a, pref_sums, table),
                            count_roads(b[i], r, t, a, pref_sums, table)});
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, m, t;
    cin >> n >> m >> t;
    vector <ll> a(n), b(m);
    for (auto& i : a) {
        cin >> i;
    }
    for (auto& j : b) {
        cin >> j; j--;
    }
    if (is_sorted(a.begin(), a.end())) {
        ll idx = b[0];
        ll dist = 0;
        while (idx > 0 && dist + a[idx] <= t) {
            dist += a[idx];
            idx--;
        }
        cout << (b[0] - idx) + (t - dist) / a[idx];
        return 0;
    }
    solve(n, m, t, a, b);
    reverse(a.begin(), a.end());
    for (auto& i : b) {
        i = n - 1 - i;
    }
    solve(n, m, t, a, b);
    cout << *max_element(max_roads, max_roads + m);
    return 0;
}
