#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define yes() cout << "YES\n"
#define no() cout << "NO\n"
using ll = long long;
using ld = long double;
using namespace std;
using namespace __gnu_pbds;

template<typename K>
using oset = tree<K, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

struct segTree {
    vector<int> t;
    int n;

    void build(int v, int l, int r, vector<int>& a) {
        if (r - l == 1) {
            t[v] = a[l];
            return;
        }

        int m = (l + r) / 2;

        build(2 * v, l, m, a);
        build(2 * v + 1, m, r, a);

        t[v] = t[2 * v] + t[2 * v + 1];
    }

    segTree(vector<int>& a) {
        n = a.size();
        t.resize(4 * n);

        build(1, 0, n, a);
    }

    int get(int v, int l, int r, int ql, int qr) {
        if (l >= qr || r <= ql) {
            return 0;
        }

        if (ql <= l && r <= qr) {
            return t[v];
        }

        int m = (l + r) / 2;

        return get(2 * v, l, m, ql, qr) + get(2 * v + 1, m, r, ql, qr);
    }

    int get(int ql, int qr) {
        return get(1, 0, n, ql, qr);
    }

    void upd(int v, int l, int r, int idx, int val) {
        if (r - l == 1) {
            t[v] = val;
            return;
        }

        int m = (l + r) / 2;

        if (idx < m) {
            upd(2 * v, l, m, idx, val);
        } else {
            upd(2 * v + 1, m, r, idx, val);
        }

        t[v] = t[2 * v] + t[2 * v + 1];
    }

    void upd(int idx, int val) {
        upd(1, 0, n, idx, val);
    }
};

void solve() {
    int n, m, T;
    cin >> n >> m >> T;

    vector<int> a(n);
    for (int& i : a) cin >> i;

    vector<int> b(m);
    for (int& i : b) {
        cin >> i;
        i--;
    }

    int ans = 0;

    vector<int> p(n + 1);
    for (int i = 1; i <= n; i++) {
        p[i] = p[i - 1] + a[i - 1];
    }

    map<int, vector<int>> mp;
    for (int i = 0; i < n; i++) {
        mp[a[i]].push_back(i);
    }

    for (auto& [f1, v] : mp) {
        for (auto& j : b) {
            int l = 0;
            int r = v.size();

            while (r - l > 1) {
                int mid = (l + r) / 2;

                if (v[mid] > j) {
                    r = mid;
                } else {
                    l = mid;
                }
            }
            int gol = v.size();
            for (int idx = max(0ll, l - 2); idx < min(gol, l + 2); idx++) {
                int i = v[idx];
                if (i < j && T >= p[j + 1] - p[i + 1]) {
                    int x = j - i + (T - p[j + 1] + p[i + 1]) / a[i];
                    ans = max(ans, x);
                } else if (i >= j && T >= p[i] - p[j]) {
                    ans = max(ans, i - j + (T - p[i] + p[j]) / a[i]);
                }
            }
        }
    }

    cout << ans << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--) {
        solve();
    }
}