#include <bits/stdc++.h>
       
    using namespace std;
    #define ll long long
    #define ld long double
    #define pll pair<long long,long long>
    #define vll vector<long long>
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define deb(x) cout << #x << "=" << x << endl
    #define F(i,a,b) for(ll i=a;i<=b;i++)
    #define RF(i,a,b) for(ll i=a;i>=b;i--)
    #define in(a,n) F(i,0,n-1)cin>>a[i]
    #define vi vector<int>
    #define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
    #define mod 998244353
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define int long long
    set < ll> primes;
     
   // int n,m;
    
   
    int ans;
    vector<int>d;
    vector<vector<int>>v;
    vector<int>par;
    vector<int>tin,tout;
     
     
    void dfs(int u,int p,int dep)
    {
        //cout<<"h\n";
        //trace3(u,p,dep);
        par[u]=p;
        d[u]=dep;
        tin[u]=++ans;
        for(auto x:v[u])
        {
            if(x==p)continue;
            
          dfs(x,u,dep+1);
        }
        tout[u]=++ans;
    }
    
    bool isancesstor(int u,int v)
    {
        return (tin[u]<=tin[v] and tout[u]>=tout[v]);
    }
    int32_t main()
    {
    	ios::sync_with_stdio(false);
        cin.tie(NULL);
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            int n,m,k;
            cin>>n>>m>>k;
            int ans=0;
            int a[n],b[m];
            for(auto&x:a)cin>>x;
            for(auto&x:b)cin>>x;
            
            for(int i=1;i<n;i++)a[i]+=a[i-1];
            for(int i=1;i<m;i++)b[i]+=b[i-1];
            
            
            map<int,int>m1,m2;
            map<int,int,greater<int>>m3,m4;
            int cnt=1;
            for(auto x:a)
            {
                m1[x]=cnt;
                m3[x]=cnt;
                cnt++;
            }
            cnt=1;
            for(auto x:b)
            {
                m2[x]=cnt;
                m4[x]=cnt;
                ++cnt;
            }
            //int ans=0;
            for(auto x:m1)
            {
                 if(x.ff>k)break;
                 ans=max(ans,x.ss);
            }
            
            for(auto x:m2)
            {
                
                 if(x.ff>k)break;
                 ans=max(ans,x.ss);
            }
            
            for(auto x:m1)
            {
                if(x.ff>k)break;
                
                auto it=m4.lower_bound(k-x.ff);
                if(it!=m4.end())
                {
                    ans=max(ans,x.ss+(*it).ss);
                }
            }
            
            for(auto x:m2)
            {
                
                if(x.ff>k)break;
                
                auto it=m3.lower_bound(k-x.ff);
                if(it!=m3.end())
                {
                    ans=max(ans,x.ss+(*it).ss);
                }
            }
            
            cout<<ans;
            
        }
        
        
       
    }

Measured memory_bytes: 56720