#include <bits/stdc++.h>
#include <experimental/random>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define int long long
using ld = long double;
const int INF = 1e18;

void solve1();

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

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    int qwerty = 1;
    // cin >> qwerty;
    while(qwerty--){
        solve1();
    }
}

void solve1(){
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> b(m);
    for(int i = 0; i < m; i++){
        cin >> b[i];
        b[i]--;
    }
    int mx = 0;
    for(int i = 0; i < m; i++){
        if(m == 1){
            int now = t;
            int cnt = 0;
            for(int j = b[i]; j >= 0; j--) {
                mx = max(mx, cnt + now / a[j]);
                if(now < a[j]) break;
                now -= a[j];
                cnt++;
            }
            now = t;
            cnt = 0;
            for(int j = b[i]; j < n; j++){
                mx = max(mx, cnt + now / a[j]);
                if(now < a[j]) break;
                now -= a[j];
                cnt++;
            }
        }
        else if(i == 0){
            int now = t;
            int cnt = 0;
            for(int j = b[i]; j >= 0; j--) {
                mx = max(mx, cnt + now / a[j]);
                if(now < a[j]) break;
                now -= a[j];
                cnt++;
            }
            now = t;
            cnt = 0;
            for(int j = b[i]; j < b[i + 1]; j++){
                mx = max(mx, cnt + now / a[j]);
                if(now < a[j]) break;
                now -= a[j];
                cnt++;
            }
        } else if(i == m - 1){
            int now = t;
            int cnt = 0;
            for(int j = b[i]; j >= b[i - 1]; j--) {
                mx = max(mx, cnt + now / a[j]);
                if(now < a[j]) break;
                now -= a[j];
                cnt++;
            }
            now = t;
            cnt = 0;
            for(int j = b[i]; j < n; j++){
                mx = max(mx, cnt + now / a[j]);
                if(now < a[j]) break;
                now -= a[j];
                cnt++;
            }
        } else{
            int now = t;
            int cnt = 0;
            for(int j = b[i]; j >= b[i - 1]; j--) {
                mx = max(mx, cnt + now / a[j]);
                if(now < a[j]) break;
                now -= a[j];
                cnt++;
            }
            now = t;
            cnt = 0;
            for(int j = b[i]; j < b[i + 1]; j++){
                mx = max(mx, cnt + now / a[j]);
                if(now < a[j]) break;
                now -= a[j];
                cnt++;
            }
        }
    }
    cout << mx;
}
