#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define int long long
using ll = long long;

typedef tree<int, null_type,less<>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int N = 3e5+10, inf = 1e18;
int a[N], b[N], pref[N], l[N], r[N];

signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, t;
    cin >> n >> m >> t;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pref[i] = pref[i-1] + a[i];
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
    }
    int k = 1;
    for (int i = 1; i <= n; i++) {
        if (b[k] == i) {
            k++;
        }
        l[i] = k-1;
        r[i] = k;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (l[i] != 0) {
            int x = b[l[i]], otv = 0;
            int y = pref[i-1] - pref[x-1];
            if (y <= t) {
                otv += i-x;
                otv += (t-y)/a[i];
            }
            ans = max(ans, otv);
        }
        if (r[i] != m+1) {
            int x = b[r[i]], otv = 0;
            int y = pref[x] - pref[i];
            if (y <= t) {
                otv += x-i;
                otv += (t-y)/a[i];
            }
            ans = max(ans, otv);
        }
    }
    cout << ans << '\n';
    return 0;
}