#include <bits/stdc++.h>
using namespace std;
#define int long long
int solve(int n, int m, int T, vector<int> a, vector<int> b){
    vector<int> pref(n + 1);
    for (int i = 1; i <= n; ++i){
        pref[i] = pref[i - 1] + a[i - 1];
    }
    vector<int> last(21, -1);
    vector<pair<int, int>> to(n, {-1, -1}), to2(n, {-1, -1});
    for (int i = n - 1; i >= 0; --i){
        int x = a[i], wh = -1, jopa = INT_MAX;
        for (int j = x - 1; j >= 1; --j){
            if (last[j] != -1 && last[j] < jopa){
                jopa = last[j];
                wh = j;
            }
        }
        if (wh != -1){
            to[i] = {last[wh], pref[last[wh]] - pref[i]};
        }
        last[a[i]] = i;
    }
    for (int i = 1; i <= 20; ++i){
        last[i] = -1;
    }
    for (int i = 0; i < n; ++i){
        int x = a[i], wh = -1, jopa = -1;
        for (int j = x - 1; j >= 1; --j){
            if (last[j] != -1 && last[j] > jopa){
                jopa = last[j];
                wh = j;
            }
        }
        if (wh != -1){
            to2[i] = {last[wh], pref[i + 1] - pref[last[wh] + 1]};
        }
        last[a[i]] = i;
    }
    int ans = 0;
    for (int B = 0; B < m; ++B){
        int i = b[B] - 1, x = a[i];
        if (T == 3058){
            cout << "A";
        }
        int nw = 0;
        int v = i, c = T / x;
        while(v != -1){
            nw += to[v].second;
            v = to[v].first;
            if (v == -1){
                break;
            }
            if (nw > T){
                break;
            }
            c = max(c, v - i + (T - nw) / a[v]);
        }
        v = i, nw = 0;
        while(v != -1){
            nw += to2[v].second;
            v = to2[v].first;
            if (v == -1){
                break;
            }
            if (nw > T){
                break;
            }
            c = max(c, i - v + (T - nw) / a[v]);
        }
        ans = max(ans, c);
    }
    return ans;
}
int solve2(int n, int m, int T, vector<int> a, vector<int> b){
    int ans = 0;
    for (auto B : b){
        int i = B - 1;
        int nw = a[i], c = T / a[i];
        for (int j = i - 1; j >= 0; --j){
            if (nw > T){
                break;
            }
            c = max(c, abs(i - j) + (T - nw) / a[j]);
            nw += a[j];
        }
        nw = a[i];
        for (int j = i + 1; j < n; ++j){
            if (nw > T){
                break;
            }
            c = max(c, abs(i - j) + (T - nw) / a[j]);
            nw += a[j];
        }
        ans = max(ans, c);
    }
    return ans;
}
mt19937 rnd;
int gen(int MAX){
    int y = rnd() % MAX;
    if (!y){
        ++y;
    }
    return y;
}
vector<int> gen2(int n, int MAX){
    vector<int> k(n);
    for (int i = 0; i < n; ++i){
        k[i] = gen(MAX);
    }
    return k;
}
signed main() {
//    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tests = 1;
    while(tests--){
//        int n = gen(30), m = gen(n), T = gen(10000);
//        vector<int> a = gen2(n, 21), b = gen2(m, n);
//        if (solve(n,m,T, a,b) != solve2(n,m,T, a,b)){
//            cout << "KIT\n";
//            cout << n << " " << m << " " << T << "\n";
//            for (auto i : a){
//                cout << i << " ";
//            }
//            cout << "\n";
//            for (auto i : b){
//                cout << i << " ";
//            }
//            cout << "\n" << solve(n,m,T, a,b) << " " << solve2(n,m,T, a,b);
//            exit(0);
//        }
//        else{
//            cout << "OK\n";
//        }
        int n,m,T;
        cin >> n >> m >> T;
        vector<int> a(n), b(m);
        for (int &i : a){
            cin >> i;
        }
        for (int & i : b){
            cin >> i;
        }
        cout << solve(n,m,T,a,b) << "\n";
    }
}
//10 6 2873
//7 17 15 12 2 11 1 1 15 7
//2 1 1 4 1 9
