let NMK: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let As: [Int64] = readLine()!.split(separator: " ").map { Int64($0)! }
let Bs: [Int64] = readLine()!.split(separator: " ").map { Int64($0)! }

var remainTime = Int64(NMK[2])
var res: Int = 0
for A in As {
    if remainTime - A < 0 {
        break
    } else {
        remainTime -= A
        res += 1
    }
}

var aIdx: Int = res-1
for bIdx in 0..<NMK[1] {
    remainTime -= Bs[bIdx]
        
    while remainTime < 0 && aIdx >= 0 {
        remainTime += As[aIdx]
        aIdx -= 1
    }
    
    if remainTime >= 0 {
        res = max(res, aIdx + bIdx + 2)
    }
}
print(res)  // (๑•ૅㅁ•๑)