import Foundation

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

func main() {
    let nmk = readInts()
    var (_, _, remaining) = (nmk[0], nmk[1], nmk[2])
    var bookA = readInts()
    var bookB = readInts()
    var ans = 0
    
    while remaining > 0 {
        if bookA.first! <= bookB.first!{
            if remaining < bookA.first! {
                print(ans)
                return
            }
            remaining -= bookA.first!
            bookA.removeFirst()
            ans += 1
            continue
        }
        if remaining < bookA.first! {
            print(ans)
            return
        }
        remaining -= bookB.first!
        bookB.removeFirst()
        ans += 1
    }
    
}
main()
