#include "bits/stdc++.h"

using namespace std;

template<class T>
istream& operator>>(istream &is, vector<T> &vec) {
      for (auto &elem: vec) is >> elem;
      return is;
}
template<class T>
ostream& operator<<(ostream &os, const vector<T> &vec) {
      for (auto &elem: vec) os << elem << ' ';
      os << '\n';
      return os;
}
#define int long long
int n, m, t;
vector<int> a, b, ans;
vector<int> p;

int cost(int j, int i) {
      int res = (i - j + 1) + (t - (p[i + 1] - p[j])) / a[j];
      return res;
}

void rec(int l, int r, int lx, int rx) {
      if (l > r) return;
      int mid = (l + r) >> 1;
      int opt = lx;
      for (int i = lx; i <= min(rx, mid); ++i) {
            int now = cost(i, mid);
            if (now > ans[mid]) {
                  ans[mid] = now;
                  opt = lx;
            }
      }

      rec(l, mid - 1, lx, opt);
      rec(mid + 1, r, opt, rx);
}

void calc() {
      ans.assign(n, 0);
      rec(0, n - 1, 0, n - 1);
}

signed main() {
#ifdef LOCAL
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
#else
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
#endif
      cin >> n >> m >> t;
      a.resize(n), b.resize(m);
      cin >> a >> b;

      for (int &i: b) i--;

      p.resize(n + 1);
      for (int i = 0; i < n; ++i) p[i + 1] = p[i] + a[i];

      calc();
      vector<int> ans1 = ans;
      std::reverse(a.begin(), a.end());
      p[0] = 0;
      for (int i = 0; i < n; ++i) p[i + 1] = p[i] + a[i];
      calc();
      vector<int> ans2 = ans;
      reverse(ans2.begin(), ans2.end());
//      cout << ans1 << ans2;

      int res = 0;
      for (int x: b) res = max(res, max(ans1[x], ans2[x]));
      cout << res << endl;
}