#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = int;
using ld = long double;
using pii = pair<ll, ll>;

#define all(v) v.begin(), v.end()
#define len(v) (ll)v.size()

mt19937 rnd(525252);

const ll INF = 1e9, SZ = 30, MOD = 1e9 + 7;
const ld eps = 1e-8, pi = acosl(-1);



void solve() {
    ll n, m, t; cin >> n >> m >> t;
    vector<ll>a(n), b(m);
    for (auto &i : a) {
        cin >> i;
    }
    for (auto &i : b){
        cin >> i;
        i--;
    }
    vector<ll>pref(n);
    pref[0] = a[0];
    for (ll i = 1; i < n; ++i) pref[i] = pref[i - 1] + a[i];
    vector<vector<ll>>nearest1(n, vector<ll>(SZ, -1));
    vector<vector<ll>>nearest2(n, vector<ll>(SZ, -1));
    vector<ll>pos(SZ, -1);
    for (ll i = 0; i < n; ++i){
        for (ll d = 0; d < SZ; ++d){
            nearest1[i][d] = pos[d];
        }
        pos[a[i]] = i;
    }

    for (auto &i : pos) i = -1;
    for (ll i = n - 1; i > 0; --i){
        for (ll d = 0; d < SZ; ++d){
            nearest2[i][d] = pos[d];
        }
        pos[a[i]] = i;
    }

    ll ans = 0;
    for (auto &i : b) {
        for (auto &fn: nearest1[i]) {
            if (fn == -1) continue;
            ll time = abs(pref[i] - pref[fn]);
            if (i < fn) time += a[i] - a[fn];
            if (time > t) continue;
            ll cur = abs(fn - i) + (t - time) / a[fn];
            ans = max(ans, cur);
//            cout << i << ' ' << fn << ' ' << cur << '\n';

        }
    }
    for (auto &i : b) {
        for (auto &fn: nearest2[i]) {
            if (fn == -1) continue;
            ll time = abs(pref[i] - pref[fn]);
            if (i < fn) time += a[i] - a[fn];
            if (time > t) continue;
            ll cur = abs(fn - i) + (t - time) / a[fn];
            ans = max(ans, cur);
//            cout << i << ' ' << fn << ' ' << cur << '\n';

        }
    }

    cout << ans;
}

int main()
{
    ll t = 1;
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
//    cin >> t;

    while (t--) {
        solve();
        cout << '\n';
    }
}
