#ifndef LOCAL
  #pragma GCC optimize("Ofast,unroll-loops")
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef LOCAL
  #pragma GCC target("avx,avx2,fma")
#endif

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define all(x) begin(x), end(x)
#define isz(x) (int)size(x)

mt19937 rng;

struct treap {
  struct node {
    int key, val, mx, sz, y;
    node* l;
    node* r;

    node(int k, int v) : key(k), y(rng()), val(v), mx(v), sz(1), l(0), r(0) {}
  };

  node* root;

  treap() : root(0) {}

  int get_mx(node* n) {
    return n ? n->mx : 0;
  }

  int get_sz(node* n) {
    return n ? n->sz : 0;
  }

  void update(node* n) {
    if (!n) return;
    n->sz = 1 + get_sz(n->l) + get_sz(n->r);
    n->mx = max({n->val, get_mx(n->l), get_mx(n->r)});
  }

  node* merge(node* a, node* b) {
    if (!a || !b) return a ? a : b;
    if (a->y > b->y) {
      a->r = merge(a->r, b);
      update(a);
      return a;
    }
    b->l = merge(a, b->l);
    update(b);
    return b;
  }

  pair<node*, node*> split_by_key(node* n, int k) {
    if (!n) return {0, 0};
    if (n->key > k) {
      auto [a, b] = split_by_key(n->l, k);
      n->l = b;
      update(n);
      return {a, n};
    }
    auto [a, b] = split_by_key(n->r, k);
    n->r = a;
    update(n);
    return {n, b};
  }

  pair<node*, node*> split_by_size(node* n, int k) {
    if (!n) return {0, 0};
    if (get_sz(n->l) >= k) {
      auto [a, b] = split_by_size(n->l, k);
      n->l = b;
      update(n);
      return {a, n};
    }
    auto [a, b] = split_by_size(n->r, k - 1 - get_sz(n->l));
    n->r = a;
    update(n);
    return {n, b};
  }

  void insert(int k, int v) {
    auto [a, b] = split_by_key(root, k);
    auto [c, d] = split_by_key(b, k + 1);
    root = merge(a, merge(new node(k, v), d));
  }

  pair<int, int> get(int k) {
    auto [a, b] = split_by_size(root, k);
    auto [c, d] = split_by_size(b, 1);
    assert(c);
    pair<int, int> ans = {c->key, c->val};
    root = merge(a, merge(c, d));
    return ans;
  }

  int max_ind(int k) {
    auto [a, b] = split_by_key(root, k);
    int ans = get_mx(a);
    root = merge(a, b);
    return ans;
  }
};

int n, T;

vector<int> Calc(const vector<int>& a) {
  vector<ll> p(n + 1);
  for (int i = 0; i < n; ++i) {
    p[i + 1] = p[i] + a[i];
  }
  treap pos;
  vector<int> cnt(n);
  for (int i = 0; i < n; ++i) {
    pos.insert(a[i], i);
    {
      auto [val, j] = pos.get(0);
      if (val <= a[i] && T >= p[i + 1] - p[j + 1]) {
        cnt[i] = max<ll>(cnt[i], i - j + (T - (p[i + 1] - p[j + 1])) / val);
      }
    }
    {
      int j = pos.max_ind(a[i] + 1);
      int val = a[j];
      if (val <= a[i] && T >= p[i + 1] - p[j + 1]) {
        cnt[i] = max<ll>(cnt[i], i - j + (T - (p[i + 1] - p[j + 1])) / val);
      }
    }
  }
  return cnt;
}

void solve() {
  int m;
  cin >> n >> m >> T;
  vector<int> a(n);
  for (auto& it : a) {
    cin >> it;
  }
  vector<int> b(m);
  for (auto& it : b) {
    cin >> it;
  }
  auto c1 = Calc(vector<int>(a.begin(), a.end()));
  auto c2 = Calc(vector<int>(a.rbegin(), a.rend()));
  reverse(all(c2));
  vector<int> cnt(n);
  for (int i = 0; i < n; ++i) cnt[i] = max(c1[i], c2[i]);
  int ans = 0;
  for (auto it : b) {
    ans = max(ans, cnt[it - 1]);
  }
  cout << ans << '\n';
}

signed main() {
  cin.tie(0)->sync_with_stdio(0);
  int t = 1;
  // cin >> t;
  for (int i = 0; i < t; ++i) {
    solve();
  }
}