#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, One, Pow, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize, m: usize, k: usize,
        mut a: [usize; n],
        mut b: [usize; m]
    }

    let ta = Accumulate::from(&a);
    let tb = Accumulate::from(&b);

    // let k: usize = k;
    let mut ans = 0usize;
    for read_in_a in 0..=n {
        if k < ta[read_in_a] {
            break;
        }
        let rest = k - ta[read_in_a];
        let read_in_b = binary_search(|x| tb[x] <= rest, 0, m).unwrap();
        // dbg!(read_in_a, read_in_b, rest);
        ans = max(ans, read_in_a + read_in_b);
    }

    println!("{}", ans);
}

/// 累積和型
/// Vec<T: Add> ->
///
/// 初期化 O(n)
/// 区間sum O(1)
///
/// 逆操作はimos法、
#[derive(PartialEq, Clone, Debug)]
pub struct Accumulate<T>(Vec<T>);
impl<T: Zero + Copy + Add<Output = T> + Sub<Output = T>> Accumulate<T> {
    /// 累積和をとります
    pub fn from(v: &[T]) -> Self {
        let mut res = Vec::with_capacity(v.len() + 1);
        let mut i: T = zero();
        res.push(i);
        for e in v {
            i = i + *e;
            res.push(i);
        }
        Accumulate(res)
    }
    /// 累積和を利用して`[i, j)`間の総和を`O(1)`で求める
    pub fn get_pertical_sum(&self, i: usize, j: usize) -> T {
        self[j] - self[i]
    }
}
impl<T: Zero + Add<Output = T> + Copy> Index<usize> for Accumulate<T> {
    type Output = T;
    fn index(&self, index: usize) -> &Self::Output {
        &self.0[index]
    }
}

/// # Usage
///
/// `T`は基本的にusizeが入る想定
///
/// `pred`について`l`側が`true`、
/// `r`側が`false`を返すような単調性を持っているとき、
///
/// `pred`を満たす`T`の中で最も大きいものを求める。
///
/// 最初に`l`と`r`について`pred`がそれぞれ`true`、`false`を返すかどうかを調べるので、
/// 範囲は閉空間で指定して良い。
///
/// 返り値`res`は必ず、
///
/// Some(inner) (l <= inner <= r) | None
///
/// になる
///
/// ```rust
/// use prcn_lib::binary_search::binary_search;
///
/// let v = vec![1, 3, 3, 3, 4, 6, 7, 7, 8, 10];
/// assert_eq!(3, binary_search(|i| v[i] < 4, 0, v.len() - 1).unwrap());
/// assert_eq!(9, binary_search(|i| v[i] <= 10, 0, v.len() - 1).unwrap());
/// ```
pub fn binary_search<T, F>(pred: F, l: T, r: T) -> Option<T>
where
    T: Add<Output = T> + Div<Output = T> + PartialEq + Copy + From<u8>,
    F: Fn(T) -> bool,
{
    if !pred(l) {
        return None;
    }
    if pred(r) {
        return Some(r);
    }
    let mut l = l;
    let mut r = r;
    let two = T::from(2);
    loop {
        let m = (l + r) / two;
        if l == m {
            break Some(l);
        }
        if pred(m) {
            l = m;
        } else {
            r = m;
        }
    }
}


Measured memory_bytes: 12436