#include <bits/stdc++.h>

#define all(cont) cont.begin(), cont.end()

using std::cin, std::cout, std::vector, std::set, std::pair, std::string, std::map, std::unordered_map, std::bitset, std::unordered_set;
using std::multiset;

#include <ext/pb_ds/assoc_container.hpp>
template <typename T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <typename T, typename V>
using ht = __gnu_pbds::gp_hash_table<T, V>;

using i32 = int; using i64 = long long;
using u32 = unsigned int; using u64 = unsigned long long;
using f32 = float; using f64 = long double;
using pi32 = std::pair<i32, i32>; using pi64 = std::pair<i64, i64>;
using vi32 = std::vector<i32>; using vi64 = std::vector<i64>;
using vvi32 = std::vector<vi32>; using vvi64 = std::vector<vi64>;
using vpi32 = std::vector<pi32>; using vpi64 = std::vector<pi64>;
using vvpi32 = std::vector<vpi32>; using vvpi64 = std::vector<vpi64>;
using si32 = std::set<i32>; using si64 = std::set<i64>;
using spi32 = std::set<pi32>; using spi64 = std::set<pi64>;
using mpi32 = std::map<i32, i32>; using mpi64 = std::map<i64, i64>;
using umpi32 = std::unordered_map<i32, i32>; using umpi64 = std::unordered_map<i64, i64>;

using i128 = __int128; using u128 = unsigned int; using f128 = __float128;

template <typename T>
using v = std::vector<T>;
template <typename T, typename comp = std::less<T>>
using s = std::set<T, comp>;
template <typename T, typename V>
using p = std::pair<T, V>;
template <typename T, typename V>
using m = std::map<T, V>;
template <typename T, typename V>
using um = std::unordered_map<T, V>;

template <typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &rhs) {
    for (auto&& i : rhs)
        is >> i;
    return is;
}
template <typename T>
std::ostream& operator<<(std::ostream &os, std::vector<T> const &rhs) {
    for (auto const& i : rhs) {
        os << i << " ";
    }
    return os;
}
template <typename T, typename V>
std::istream& operator>>(std::istream &is, std::pair<T, V> &rhs) {
    is >> rhs.first >> rhs.second;
    return is;
}
template <typename T, typename V>
std::ostream& operator<<(std::ostream &os, std::pair<T, V> const& rhs) {
    os << rhs.first << " " << rhs.second << "\n";
    return os;
}

std::mt19937_64 ru64(std::chrono::steady_clock::now().time_since_epoch().count());

#define MULTITEST_ 0
#define PRECALCULATE_ 0

struct dot {
    i64 x, y;
    i64 operator%(dot const &rhs) {
        return x * rhs.y - y * rhs.x;
    }
    i64 operator*(dot const &rhs) {
        return x * rhs.x + y * rhs.y;
    }
    dot operator-(dot const &rhs) const {
        return dot{.x = x - rhs.x, .y = y - rhs.y};
    }
};

v<dot> hull(v<dot> pnt) {
    v<dot> rs;
    for (i32 i = 0; i < pnt.size(); ++i) {
        if (pnt[i].x < pnt[0].x || pnt[i].x == pnt[0].x && pnt[i].y < pnt[0].y) {
            std::swap(pnt[i], pnt[0]);
        }
    }
    std::sort(pnt.begin() + 1, pnt.end(), [&] (dot const &lhs, dot const &rhs) {
        dot a = lhs - pnt[0], b = rhs - pnt[0];
        if (a % b == 0) {
            return a * a < b * b;
        }
        return a % b > 0;
    });
    for (i32 i = 0; i < pnt.size(); ++i) {
        for (; rs.size() > 2;) {
            dot a = pnt[i] - rs.back();
            dot b = rs.back() - rs[rs.size() - 2];
            if (a % b <= 0) {
                rs.pop_back();
            }
        }
        rs.push_back(pnt[i]);
    }
    return pnt;
}

struct treap {
    struct nd {
        i64 val;
        i32 sz;
        nd* ls = nullptr;
        nd* rs = nullptr;
        nd(i64 val_) {
            sz = 1;
            val = val_;
        }
    };
    void upd(nd* n) {
        if (!n) return;
        n->sz = sz(n->ls) + 1 + sz(n->rs);
    }
    i32 sz(nd* n) {
        return n ? n->sz : 0;
    }
    i64 val(nd* n) {
        return n ? n->val : 0;
    }
    using pnd = p<nd*, nd*>;
    pnd split(i32 k, nd* n) {
        if (!n)
            return {0, 0};
        if (sz(n->ls) < k) {
            auto [l, r] = split(k - sz(n->ls), n->rs);
            n->rs = l;
            upd(n);
            return {n, r};
        } else {
            auto [l, r] = split(k, n->ls);
            n->ls = r;
            upd(n);
            return {l, n};
        }
    }
    nd* merge(nd* l, nd* r) {
        if (!l) return r;
        if (!r) return l;
        if (sz(l) > ru64() % (sz(l) + sz(r))) {
            l->rs = merge(l->rs, r);
            upd(l);
            return l;
        } else {
            r->ls = merge(l, r->ls);
            upd(r);
            return r;
        }
    }
};

struct solution {
    auto operator()(i32 n_test = 0) -> void {
        i32 n, m, t;
        cin >> n >> m >> t;
        vvi64 dp(1, vi64(n));
        vi64 a(n);
        cin >> a;
        vi64 b(m);
        cin >> b;
        for (auto&& j : b) --j;
        vi64 pref(n + 1);
        for (i32 i = 0; i < n; ++i) {
            pref[i + 1] = pref[i] + a[i];
        }
        vvi32 upl(n, vi32(20));
        vvi32 upr(n, vi32(20));
        vi32 lmin(n), rmin(n);
        vpi32 st;
        for (i32 i = 0; i < n; ++i) {
            for (; st.size() && st.back().first >= a[i];)
                st.pop_back();
            lmin[i] = (st.empty() ? i : st.back().second);
            st.push_back({a[i], i});
        }
        st.clear();
        for (i32 i = n - 1; i >= 0; --i) {
            for (; st.size() && st.back().first >= a[i];)
                st.pop_back();
            rmin[i] = (st.empty() ? i : st.back().second);
            st.push_back({a[i], i});
        }
        for (i32 i = 0; i < n; ++i) {
            upl[i][0] = lmin[i];
            for (i32 j = 1; j < 20; ++j) {
                upl[i][j] = upl[upl[i][j - 1]][j - 1];
            }
        }
        for (i32 i = n - 1; i >= 0; --i) {
            upr[i][0] = rmin[i];
            for (i32 j = 1; j < 20; ++j) {
                upr[i][j] = upr[upr[i][j - 1]][j - 1];
            }
        }
        auto count_r = [&] (i32 j, i32 d) {
            i32 jj = j;
            for (i32 i = 19; i >= 0; --i) {
                if (d - (1 << i) >= 0)
                    jj = upr[jj][i], d -= (1 << i);
            }
            i64 sum = pref[jj] - pref[j];
            if (t - sum < 0)
                return LONG_LONG_MIN;
            return (jj - j) + (t - sum) / a[jj];
        };
        auto count_l = [&] (i32 j, i32 d) {
            i32 jj = j;
            for (i32 i = 19; i >= 0; --i) {
                if (d - (1 << i) >= 0)
                    jj = upl[jj][i], d -= (1 << i);
            }
            i64 sum = pref[j + 1] - pref[jj + 1];
            if (t - sum < 0)
                return LONG_LONG_MIN;
            return (j - jj) + (t - sum) / a[jj];
        };
        i64 rs = 0;
        for (auto& j : b) {
            i32 l = 0, r = n;
            for (; r - l > 1;) {
                i32 m1 = (2 * l + r) / 3;
                i32 m2 = (l + 2 * r) / 3;
                if (count_l(j, m1) > count_l(j, m2))
                    r = m2;
                else
                    r = m1;
            }
            for (i32 i = l - 20; i <= r + 20; ++i) {
                rs = std::max(rs, count_l(j, i));
            }
        }
        for (auto& j : b) {
            i32 l = 0, r = n;
            for (; r - l > 1;) {
                i32 m1 = (2 * l + r) / 3;
                i32 m2 = (l + 2 * r) / 3;
                if (count_r(j, m1) > count_r(j, m2))
                    r = m2;
                else
                    r = m1;
            }
            for (i32 i = l - 20; i <= r + 20; ++i) {
                rs = std::max(rs, count_r(j, i));
            }
        }
        cout << rs;
    }
    void inline static precalculate();
};

auto main() -> i32 {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
#if PRECALCULATE_
    solution::precalculate();
#endif
#if MULTITEST_
    i32 t; cin >> t;
    for (i32 i = 0; i < t; ++i) {
        solution solve; solve(i);
    }
#else
    solution solve; solve();
#endif
    return 0;
}
