#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;

int main()
{
  long long minutes=0;
  int ans=0,j; 
  int n,m,k;
  cin >> n >> m >> k;
  vector<int> a(n);
  vector<int> b(m);
  rep(i,n) cin >> a[i];
  rep(i,m){
    cin >> b[i];
    minutes+=b[i];
  }
  
  j=m;  
  rep(i,n+1){
    while(k<minutes && j>0){
      --j;
      minutes-=b[j];
    }
    if(k>=minutes)
      ans=max(ans,i+j);
    if(i==n) break;
    minutes+=a[i];
  }
  cout << ans << endl;
  return 0;
}