#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define len(x) (int)x.size()
#define all(x) x.begoin(), x.end()
const ll INF = 1e18;
const int INFi = 1e9;

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

    vector<int> a(n), b(m);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < m; ++i) cin >> b[i];

    int ans = 0;

    for (int k = 1; k + 1 < m; ++k) {
        int i = b[k] - 1;
        int mx = 0, cur = 0, cnt = 0;
        for (int j = i; j <= b[k+1] - 1; ++j) {
            if (cur >= t) break;
            int val = max(0, (t - cur) / a[j]);
            mx = max(mx, val + cnt);
            cur += a[j];
            ++cnt;
        }

        cur = 0, cnt = 0;
        for (int j = i; j >= b[k-1] - 1; --j) {
            if (cur >= t) continue;
            int val = max(0, (t - cur) / a[j]);
            mx = max(mx, val + cnt);
            cur += a[j];
            ++cnt;
        }

        ans = max(ans, mx);
    }

    int i = b[0] - 1;
    int mx = 0, cur = 0, cnt = 0;
    for (int j = i; j < n; ++j) {
        if (cur >= t) break;
        int val = max(0, (t - cur) / a[j]);
        mx = max(mx, val + cnt);
        cur += a[j];
        ++cnt;
    }

    cur = 0, cnt = 0;
    for (int j = i; j >= 0; --j) {
        if (cur >= t) continue;
        int val = max(0, (t - cur) / a[j]);
        mx = max(mx, val + cnt);
        cur += a[j];
        ++cnt;
    }

    ans = max(ans, mx);

    i = b[m-1] - 1;

    mx = 0, cur = 0, cnt = 0;
    for (int j = i; j < n; ++j) {
        if (cur >= t) break;
        int val = max(0, (t - cur) / a[j]);
        mx = max(mx, val + cnt);
        cur += a[j];
        ++cnt;
    }

    cur = 0, cnt = 0;
    for (int j = i; j >= 0; --j) {
        if (cur >= t) continue;
        int val = max(0, (t - cur) / a[j]);
        mx = max(mx, val + cnt);
        cur += a[j];
        ++cnt;
    }

    ans = max(ans, mx);

    cout << ans << '\n';
}

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w", stdout);
#endif

    int t = 1;
//    cin >> t;
    while(t--) {
        solve();
    }

    return 0;
}