#include <bits/stdc++.h>

using namespace std;


int main() {
  int n,m;
  long long k;
  cin>>n>>m>>k;
  vector<long long> a(n+1,0),b(m+1,0);
  for(int i=0;i<n;++i){
    cin>>a[i+1];
    a[i+1]+=a[i];
  }
  for(int i=0;i<m;++i){
    cin>>b[i+1];
    b[i+1]+=b[i];
  }
 
  int ans = 0;
  for(int i=0;i<=n;++i){
    long long rest=k-a[i];
    if(rest<0) continue;
    int temp=upper_bound(b.begin(),b.end(),rest)-b.begin()-1+i;
    ans=ans<temp?temp:ans;
  }
  cout << ans << endl;
  return 0;
}
