//                 _                      
//                (_)                     
// _ __ ___   __ _ _  ___  _ __ _ __ ___  
//| '_ ` _ \ / _` | |/ _ \| '__| '__/ _ \ 
//| | | | | | (_| | | (_) | |  | | | (_) |
//|_| |_| |_|\__,_| |\___/|_|  |_|  \___/ 
//               _/ |                     
//              |__/                      
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
  
typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vbl;
typedef tree<
    pll,
    null_type,
    less<pll>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;

#define majorro cout.precision(20); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define forn(i, n) for(ll (i) = 0; (i) < (n); ++(i))
#define fornm(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define rfornm(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define readvec(vector, n) {ll temp_vec_val;forn(inc, n){cin >> temp_vec_val;vector.push_back(temp_vec_val);}}
#define printvec(vector, delimeter) {ll length_of_vector=vector.size();\
                                    forn(elementvec, length_of_vector){cout << vector[elementvec] << delimeter;}}
#define printarr(arr, length, delimeter) {forn(elementarr, length){cout << arr[elementarr] << delimeter;}}
#define all(vector) (vector).begin(), (vector).end()
#define rall(vector) (vector).rbegin(), (vector).rend()
#define endl "\n"
  
struct pair_hash
{
    template <class T1, class T2>
    std::size_t operator() (const std::pair<T1, T2>& pair) const
    {
        return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
    }
};
 
const ldbl EPS = 1e-6;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const ll MOD = 3037000499;
// const ull MOD = 1000000000000000003;
const ll INF = 1e18;
const ldbl pi = 2 * acos(0.0);
ll n, m, k, p, q, t, sum = 0, cnt= 0;
ll mx = -INF;
ll mn = INF;
bool flag = 0;
vll v;
str s = "", s1, s2;
char c;
 
void bad_solve(){}


void solve() //set.merge() -> c++17
//DELET DEBUG OUTPUT!11!1
//"YES"/"NO" OUTPUT!!!!
//__builtin_popcountll() -> __popcnt64() from <intrin.h>
{
    cin >> n >> m >> k;
    vll a,b;
    readvec(a,n);
    readvec(b,m);
    vll pref(m, 0);
    pref[0] = b[0];
    ll ans = 0;
    if(b[0] <= k) ans = 1;
    fornm(i, 1, m)
    {
        pref[i] = pref[i-1]+b[i];
        if(pref[i] <= k) ans = i+1;
    }
    forn(i,n)
    {
        sum += a[i];
        if(sum > k) break;
        ans = max(i+1, ans);
        ll l = 0, r = m-1;
        while(l<r)
        {
            ll mid = (l+r)/2;
            if(pref[mid] < k-sum) l = mid+1;
            else r = mid;
        }
        if(pref[l]+sum > k) --l;
        if(l == -1) continue;
        ans = max(ans, i+l+2);
    }
    cout << ans;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("F:\\repos\\projects\\contests_vsc\\in.txt", "r", stdin);
    freopen("F:\\repos\\projects\\contests_vsc\\out.txt", "w", stdout);
#endif
    majorro
    
    solve();
  
    // freopen("test.txt", "w", stdout);
    // bad_solve();
  
//  memset(v, INT_MAX, 1000*2000*sizeof(int));
  
    return 0;
}

Measured memory_bytes: 7952