import Foundation

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

let nmk = readInts()
let (_, _, remaining) = (nmk[0], nmk[1], nmk[2])
let bookA = readInts()
let bookB = readInts()
//
var countCanReadBookB = bookB.count
var readBookTime = bookB.reduce(0) { $0 + $1 }
var varRem = remaining
var ans = 0

for countReadedBookA in 0...bookA.count {
    // Aから0冊読んだ場合から検証するため
    readBookTime += countReadedBookA > 0 ? bookA[countReadedBookA - 1]: 0
    
    
    while countCanReadBookB > 0 && readBookTime > remaining {
        countCanReadBookB -= 1
        readBookTime -= bookB[countCanReadBookB]
    }
    
    if readBookTime > remaining {
        break
    }
    ans = max(ans, countReadedBookA + countCanReadBookB)
}
print(ans)







