function Main(input) {
    input = input.split("\n")
	const [n, m, k] = [...(input[0].split(" ").map( x => parseInt(x, 10)))]
	const a = (input[1].split(" ")).map( x => parseInt(x, 10) )
	const b = (input[2].split(" ")).map( x => parseInt(x, 10) )
	let sum_a = [0]
	let sum_b = [0]
	let temp = 0
	for( let i = 0; i < n; i++ ){
		temp += a[i]
		sum_a.push(temp)
	}
	temp = 0
	for( let i = 0; i < m; i++ ){
		temp += b[i]
		sum_b.push(temp)
	}
	let ap = 0
	for( let i = n; i >= 0; i-- ){
		if( sum_a[i] <= k ){
			ap = i
			break
		}
	}
	let bp = 0
	let ans = 0
	for( ; ap >= 0; ap-- ){
		while( bp+1 <= m && sum_a[ap] + sum_b[bp+1] <= k ) ++bp
		ans = ( ap+bp > ans ? ap+bp : ans )
	}
	console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))