#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,m,T;
    cin >> n >> m >> T;
    int a[n];
    ll pr[n+1];
    pr[0] = 0;
    for(int i = 0;i < n;++i)
    {
        cin >> a[i];
        pr[i+1] = pr[i] + a[i];
    }
    int b[m];
    for(int j = 0;j < m;++j)
    {
        cin >> b[j];
        b[j]--;
    }
    int tbl = -1;
    ll ans = 0;
    for(int j = 0;j < n;++j)
    {
        if(tbl < m-1 && b[tbl+1] == j)
        {
            tbl++;
        }
        if(tbl == -1)
            continue;
        int pos = b[tbl];
       // cout << j << ' ' << pos << endl;
        if(pr[j] - pr[pos] <= T)
        {
            ans = max(ans,(T - (pr[j] - pr[pos]))/a[j] + (j-pos));
        }
    }
    tbl = m;
    for(int j = n-1;j >= 0;--j)
    {
        if(tbl > 0 && b[tbl-1] == j)
        {
            tbl--;
        }
        if(tbl == m)
            continue;
        int pos = b[tbl];
        //cout << j << ' ' << pos << endl;
        if(pr[pos+1] - pr[j+1] <= T)
        {
            ans = max(ans,(T - (pr[pos+1] - pr[j+1]))/a[j] + (pos-j));
        }
    }
    cout << ans;
    return 0;
}
