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 res: Int = 0

var time: Int64 = 0
var readed: Int = 0

func dfs(aIdx: Int, bIdx: Int) {
    if time > NMK[2] {
        res = max(res, readed-1)
        return
    }    
    var kara = true
    for i in [0, 1] {
        readed += 1
        if i == 0 && aIdx+1 < As.count {
            time += As[aIdx+1]
            dfs(aIdx: aIdx+1, bIdx: bIdx)
            time -= As[aIdx+1]
        } else if bIdx+1 < Bs.count {
            kara = false
            time += Bs[bIdx+1]
            dfs(aIdx: aIdx, bIdx: bIdx+1)
            time -= Bs[bIdx+1]
        }
        readed -= 1
    }
    if kara == true {
        res = max(res, readed)
        return
    }
}
dfs(aIdx: -1, bIdx: -1)
print(res)