#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>

using ll = long long;
using ld = long double;

#define int ll
#define pii pair<int, int>
#define all(obj) obj.begin(), obj.end()
#define rall(obj) obj.rbegin(), obj.rend()
#define pb push_back

const int inf = 1e9;
const int INF = 1e18;

using namespace std;

signed main() {
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    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(n);
    for (int i=0; i<n; i++) {
        cin >> b[i];
        b[i]--;
    }

    vector<int>pref(n+1);
    pref[0] = 0;
    for (int i=1; i<=n; i++) {
        pref[i] = pref[i-1] + a[i-1];
    }

    vector<int> bl(n);
    bl[0] = 0;
    for (int i=1; i<n; i++) {
        int opt1;
        if (t-(pref[i+1]-pref[bl[i-1]+1]) >= 0) {
            opt1 = (t-(pref[i+1]-pref[bl[i-1]+1])) / a[bl[i-1]] + (i-bl[i-1]);
        }
        else opt1 = -1;
        int opt2 = t / a[i];
        if (opt1 >= opt2) {
            bl[i] = bl[i-1];
        }
        else {
            bl[i] = i;
        }
    }

    vector<int> br(n);
    br[n-1] = n-1;
    for (int i=n-2; i>=0; i--) {
        int opt1;
        if (t-(pref[br[i+1]]-pref[i]) >= 0) {
            opt1 = (t-(pref[br[i+1]]-pref[i])) / a[br[i+1]] + (br[i+1]-i);
        }
        else opt1 = -1;
        int opt2 = t / a[i];
        if (opt1 >= opt2) {
            br[i] = br[i+1];
        }
        else {
            br[i] = i;
        }
    }

    int ans = 0;
    for (int i=0; i<m; i++) {
        int pos = b[i];
        ans = max(ans, (t-(pref[pos+1]-pref[bl[pos]+1])) / a[bl[pos]] + (pos-bl[pos]));
        ans = max(ans, (t-(pref[br[pos]]-pref[pos])) / a[br[pos]] + (br[pos]-pos));
    }

    cout << ans;
}