#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long

signed main()
{
    ll n, m, T;
    cin >> n >> m >> T;
    vector<ll> a(n), b(m), p(n + 1);
    for (auto& x : a) cin >> x;
    for (auto& x : b) cin >> x, x--;
    for (int i = 1; i <= n; i++)
        p[i] = p[i - 1] + a[i - 1];
    ll j = -1, l1, l2;
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        if (j + 1 < m && b[j + 1] == i)
            j++;
        if (j >= 0) l1 = p[i] - p[b[j]];
        if (j + 1 < m) l2 = p[b[j + 1] + 1] - p[i + 1];
        if (j >= 0 && T > l1) ans = max(ans, (T - l1) / a[i] + (i - b[j]));
        if (j + 1 < m && T > l2) ans = max(ans, (T - l2) / a[i] + (b[j + 1] - i));
    }
    cout << ans << '\n';
}
