#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
//#include <cmath>
//#include <numeric>

//#pragma GCC optimize("O3, unroll-loops")
//#pragma GCC target("avx2, avx, lzcnt, popcnt, bmi, bmi2")

using namespace std;
#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> A(n);
    for (int i = 0; i < n; i++){
        cin >> A[i];
    }
    vector<int> ind(m);
    for (int i = 0; i < m; i++){
        cin >> ind[i];
        ind[i]--;
    }
    int ans = 0;
    int summ = 1e10, cnt = 0, cur = 0;
    for (int i = 0; i < n; i++){
        while(cur != m and ind[cur] < i){
            cur++;
        }
        if (cur != m and ind[cur] == i){
            summ = 0;
            cnt = 0;
        }
        if (summ <= t) {
            ans = max(ans, cnt + (t - summ) / A[i]);
        }
        summ += A[i];
        cnt++;
    }
    summ = 1e10, cnt = 0, cur = m - 1;
    for (int i = n - 1; i >= 0; i--){
        while(cur != -1 and ind[cur] > i){
            cur--;
        }
        if (cur != -1 and ind[cur] == i){
            summ = 0;
            cnt = 0;
        }
        if (summ <= t) {
            ans = max(ans, cnt + (t - summ) / A[i]);
        }
        summ += A[i];
        cnt++;
    }
    cout << ans;
}