#include <bits/stdc++.h>
#define int long long

int give(int l, int r, std::vector<int> &pref)
{
    if (l == 0)
    {
        return pref[r];
    }
    return pref[r] - pref[l - 1];
}

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, m, T;
    std::cin >> n >> m >> T;

    std::vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> a[i];
    }

    std::vector<int> b(m);
    for (int i = 0; i < m; i++)
    {
        std::cin >> b[i];
        b[i]--;
    }
    std::vector<int> pref(n);
    pref[0] = a[0];
    for (int i = 1; i < n; i++)
    {
        pref[i] = pref[i - 1] + a[i];
    }
    int now = 0;
    int best = 0;
    for (int i = 0; i < n; i++)
    {
        while (now + 1 < m && b[now + 1] <= i)
        {
            now++;
        }
        // std::cout << i << ' ' << now << std::endl;

        if (b[now] <= i)
        {
            int tmp = give(b[now], i, pref);
            if (tmp <= T)
            {
                //   std::cout << i << ' ' << b[now] << ' ' << (i - b[now] + 1) << ' ' << (T - tmp) / a[i] << ' ' << tmp << std::endl;
                best = std::max(best, (i - b[now] + 1) + (T - tmp) / a[i]);
            }
        }

        if (now + 1 < m && b[now + 1] >= i)
        {
            int tmp = give(i, b[now + 1], pref);
            if (tmp <= T)
            {
                best = std::max(best, (b[now + 1] - i + 1) + (T - tmp) / a[i]);
            }
        }
    }
    std::cout << best;
}