//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<unordered_map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<memory>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a)   a.begin(),a.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }
    //
    ModInt operator++(int) {
        auto t = *this;
        *this += 1;
        return t;
    }

    ModInt operator--(int) {
        auto t = *this;
        *this -= 1;
        return t;
    }
    ModInt operator<<(const int n){
        return ModInt(*this)*ModInt(2).pow(n);
    }
    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void a(){
    ll A;
    cin >> A;
    cout << A+A*A+A*A*A;
}
void b(){
    string S;
    string T;
    cin >> S >> T;
    ll ans = 0;
    rep(i,S.size()){
        if(S[i]!=T[i]) ans++;
    }
    cout << ans;
}
void c(){
    ll N,M,K; cin >> N >> M >> K;
    auto A = v<>(N+1,INF);
    auto B = v<>(M+1,INF);
    A[0]=0;
    B[0]=0;
    rep(i,N){
        ll t = 0;
        cin >> t;
        A[i+1] = A[i] + t;
    }

    rep(i,M){
        ll t = 0;
        cin >> t;
        B[i+1] = B[i] + t;
    }
  
    ll ans = 0;
    rep(i,N+1){
        if(A[i]>K) break;
        ll j=M-1;
        j=upper_bound(all(B),K-A[i])-B.begin()-1;
        chmax(ans,i+j);
    }
    cout << ans;
} 
    
ll dfs(ll i){ 
    unordered_map<ll,ll> memo;
    memo[1]++;
    memo[i]++;
    ll k = i;
    for(ll j=2;j*j<=i;(j+=j==2?1:2)){
        ll jj=j;
        ll ii = i;
        while(i%j==0){
            if(!memo[jj]) memo[jj]++;
            if(!memo[ii/jj]) memo[ii/jj]++;
            jj*=j;
            i/=j;
        }
    }
    return memo.size();
}

void d(){
    ll N; cin >> N;
    ll sum = 1;
    for(ll i=2;i<=N;i++){
        sum +=  dfs(i)*i;
    }
    cout << sum << endl;
}
void e(){}


int main(){
    c();
}

Measured memory_bytes: 6428