// inputに入力データ全体が入る
function Main(input) {
	var ans = 0
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n")
	// var arr = input.trim().split("\n")
	var max = input[0].split(' ').map(n => parseInt(n))[2]
	var da = input[1].split(' ').map(n => parseInt(n))
	var db = input[2].split(' ').map(n => parseInt(n))
	var now = 0
	var ai = 0
	var bi = 0

	while (now < max) {
		var read 
		var isa
		if (da[ai] == -1 && db[bi] == -1) {
			break
		} else if (da[ai] == -1 && db[bi] >= 0) {
			read = db[bi]
			isa = false
		} else if (da[ai] == -1 && db[bi] >= 0) {
			read = da[ai]
			isa = true
		} else if (da[ai] <= db[bi]) {
			read = da[ai]
			isa = true
		} else {
			read = db[bi]
			isa = false
		}

		if (now + read <= max) {
			now = now + read
			ans++
		} else {
			break
		}

		if (isa) {
			ai++
			if (da[ai] == undefined) da[ai] = -1
		} else {
			bi++
			if (db[bi] == undefined) db[bi] = -1
		}
	}


	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));