
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define ve vector
#define pb push_back
#define all(a) a.begin(), a.end()
#define first f
#define second s
using ld = double;
#define int ll
mt19937 rnd(321932);

template<class A>
istream &operator>>(istream &in, ve<A> &a) {
    for (auto &x: a)
        in >> x;
    return in;
}

template<class A>
ostream &operator<<(ostream &out, ve<A> a) {
    for (auto &x: a)
        out << x << ' ';
    return out << '\n';
}

ve<int> x;
struct lct {
    int n;
    struct func {
        ld a, b;
        [[nodiscard]] int get(int i) const {
            return (int)(a * x[i] + b);
        }
    };
    ve<func> t;
    void add(int v, int l, int r, func nw) {
        int m = (l + r)/2;
        auto &old = t[v];
        if (old.get(m) < nw.get(m))
            swap(old, nw);
        if (l + 1 == r)
            return;
        if (nw.get(l) >= old.get(l))
            add(2*v+1, l, m, nw);
        else if (nw.get(r-1) >= old.get(r-1))
            add(2*v+2, m, r, nw);
    }

    void add(ld a, ld b) {
        add(0, 0, n, {a, b});
    }

    void add(int v, int l, int r, int ql, int qr, func nw) {
        if (l >= qr || ql >= r)
            return;
        if (ql <= l && r <= qr) {
            add(v, l, r, nw);
            return;
        }
        int m = (l + r)/2;
        add(2*v+1, l, m, ql, qr, nw);
        add(2*v+2, m, r, ql, qr, nw);
    }

    void add(int l, int r, ld a, ld b) {
        add(0, 0, n, l, r, {a, b});
    }

    int get(int v, int l, int r, int i) {
        if (l + 1 == r)
            return t[v].get(i);
        int m = (l + r)/2;
        if (i < m)
            return max(t[v].get(i), get(2*v+1, l, m, i));
        else
            return max(t[v].get(i), get(2*v+2, m, r, i));
    }

    int get(int i) {
        return (int)get(0, 0, n, i);
    }

    lct() {
        n = x.size();
        t.assign(4*n, {0, -1e18});
    }
};

int32_t main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m, T;
    cin >> n >> m >> T;
    ve<int> a(n), b(m);
    cin >> a >> b;
    x.assign(n + 1, 0);
    for (int i = 0;  i< n; ++i)
        x[i+1] = x[i] + a[i];
    int k = m - 1;
    ve<int> ans(m, 0);
    lct t;
    for (int i = n - 1; i >= 0; --i) {
        t.add(lower_bound(all(x), x[i]-T) - x.begin(), n+1, 1/ld(a[i]), i + (T - x[i])/ld(a[i]));
        if (k >= 0 && b[k] == i + 1) {
//            for (int i = b[k] - 1; i < n && T-x[i]+x[b[k]-1] >= 0; ++i) {
//                ans[k] = max(ans[k], i - b[k] + 1 + (T-x[i]+x[b[k]-1])/a[i]);
//            }
            ans[k] = max(ans[k], t.get(i) - i);
            k--;
        }
    }
    // cout << ans;
    t = lct();
    k = 0;
    for (int i = 0; i < n; ++i) {
        t.add(0, upper_bound(all(x), T+x[i+1]) - x.begin(), -1/ld(a[i]), -i + (T+x[i+1])/ld(a[i]));
        if (k < m && b[k] == i + 1) {
//            for (int i = b[k] - 1; i >= 0 && T+x[i+1]-x[b[k]] >= 0; --i) {
//                ans[k] = max(ans[k], b[k] - 1 - i + (T+x[i+1]-x[b[k]])/a[i]);
//            }
            ans[k] = max(ans[k], t.get(i+1) + i);
            k++;
        }
    }
    // cout << ans;
    cout << *max_element(all(ans));
}
