/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

#include<bits/stdc++.h>
using namespace std;

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<int>           vci;
typedef     vector<ll>            vcl;
typedef     pair<int,int>         pii;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     vector<pii>           vpi;
typedef     map<ll,ll>            mll;
typedef     map<int,int>          mii;
typedef     multiset<int>         msi;
typedef     multiset<ll>          msl;
using pql=priority_queue<ll,vcl,less<ll>>;
using pqg=priority_queue<ll,vcl,greater<ll>>;

#define    sci(x)         scanf("%d",&x)
#define    scii(x,y)      scanf("%d%d",&x,&y)
#define    sciii(x,y,z)   scanf("%d%d%d",&x,&y,&z)
#define    scl(x)         scanf("%lld",&x)
#define    scll(x,y)      scanf("%lld%lld",&x,&y)
#define    sclll(x,y,z)   scanf("%lld%lld%lld",&x,&y,&z)
#define    sclu(x)        scanf("%llu",&x)
#define    scc(x)         scanf("%c",&x)
#define    scs(x)         scanf("%s",&x)
#define    pfi(x)         printf("%d\n",x)
#define    pfii(x,y)      printf("%d %d\n",x,y)
#define    pfl(x)         printf("%lld\n",x)
#define    pfll(x,y)      printf("%lld %lld\n",x,y)
#define    pflu(x)        printf("%llu\n",x)
#define    pfs(s)         printf("%s",s.c_str())
#define    nel            printf("\n")
#define    nn             '\n'///endl

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<"\n"
#define    no             cout<<"NO"<<"\n"

#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    no1(n)         __builtin_popcountll(n)
#define    strl(a)        atoi(a.c_str())
string lstr(ll n){stringstream ss;ss<<n;return ss.str();}

const   int  N2  =   1e6+7;
const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;

int main() {ikarus_101

      ll n,m,i,j,k,x;

      cin >> n >> m >> k;

      vcl a(n),b(m);

      vin(a);vin(b);

      ll tot = 0;
      rep(i,m) tot += b[i];
      j=m;
      ll ans = 0;
      rep(i,n+1)
      {
          while(tot>k and j>0)
          {
                --j;
                tot-=b[j];
          }
          if(tot>k) break;
          ans = max(ans,i+j);
          if(i==n) break;
          tot += a[i];
      }
      cout << ans << nn;









      return 0;
}


Measured memory_bytes: 6360