#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

trait Group:
    std::ops::Add<Output = Self>
    + std::ops::Sub<Output = Self>
    + std::ops::Neg<Output = Self>
    + std::iter::Sum
    + Clone
    + Copy
{
    fn zero() -> Self;
}
impl Group for i32 {
    fn zero() -> Self {
        0
    }
}
impl Group for i64 {
    fn zero() -> Self {
        0
    }
}
impl Group for f32 {
    fn zero() -> Self {
        0.0
    }
}
impl Group for f64 {
    fn zero() -> Self {
        0.0
    }
}

struct Cumsum<T>(Vec<T>);
impl<T: Group> Cumsum<T> {
    fn new(xs: &Vec<T>) -> Cumsum<T> {
        let mut ac = T::zero();
        let mut arr = vec![T::zero(); xs.len()];
        for i in 0..arr.len() {
            ac = ac + xs[i];
            arr[i] = ac;
        }
        Cumsum(arr)
    }
    fn sum_up(&self, idx: usize) -> T {
        // [0, idx)
        if idx > 0 {
            self.0[idx - 1]
        } else {
            T::zero()
        }
    }
    fn sum(&self, range: std::ops::Range<usize>) -> T {
        // sum(i..j) = sum of [i, j)
        assert!(range.start <= range.end);
        self.sum_up(range.end) - self.sum_up(range.start)
    }
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    let k: i64 = sc.cin();
    let xs: Vec<i64> = sc.vec(n);
    let ys: Vec<i64> = sc.vec(m);
    let cx = Cumsum::new(&xs);
    let cy = Cumsum::new(&ys);
    let mut ans = 0;
    for i in 0..=n {
        let a = cx.sum(0..i);
        if a > k {
            break;
        }
        let j = if a + cy.sum(0..m) <= k {
            m
        } else {
            let mut left = 0; // ok
            let mut right = m;
            for _ in 0..100 {
                let mid = (left + right) / 2;
                if a + cy.sum(0..mid) <= k {
                    left = mid;
                } else {
                    right = mid;
                }
            }
            left
        };
        ans = max!(ans, i + j);
    }
    put!(ans);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 20364