#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;

#define int ll
#define pb push_back
#define pf push_front
#define in insert
#define f first
#define s second

mt19937_64 rnd;

const int inf = 1e17, N = 4e5, mod = 1e9 + 7;

signed main(){
  int n, m, t;
  cin >> n >> m >> t;
  vector<int> a(n), b(m), pr(n);
  for(int &x : a) cin >> x;
  for(int &x : b){
    cin >> x;
    x--;
  }
  pr[0] = a[0];
  for(int i = 1; i < n; i++) pr[i] = a[i] + pr[i - 1];
  int beg = 0, res = 0;
  for(int i = 0; i < n; i++){
    if(beg + 1 < m && b[beg + 1] == i) beg++;
    //cout << b[beg] << ' ' << i << ' ';
    int l = pr[i] - pr[b[beg]] + a[b[beg]] - a[i];
    if(t >= l){
      int k = (t - l) / a[i] + i - b[beg];
      if(res < k) res = k;
    }
    if(beg + 1 < m){
      //cout << b[beg + 1];
      int r = pr[b[beg + 1]] - pr[i];
      if(t >= r){
        int k = (t - r) / a[i] + b[beg + 1] - i;
        if(res < k) res = k;
      }
    }
    //cout << '\n';
  }
  for(int i = 0; i < m; i++){
    int nt = t, st = 0;
    for(int j = b[i]; j >= 0; j--){
      if(nt - a[j] < 0) break;
      nt -= a[j]; st++;
    }
    if(res < st) res = st;
    nt = t; st = 0;
    for(int j = b[i]; j < n; j++){
      if(nt - a[j] < 0) break;
      nt -= a[j]; st++;
    }
    if(res < st) res = st;
  }
  cout << res;
  /*
  for(int i = 0; i < n; i++){
    int l = 0, r = i + 1;
    while(l < r){
      int m = l + r >> 1;
      if()
    }
  }
  */
  return 0;
}