//let s = readLine()!
//let t = readLine()!
//
//print(zip(s, t).filter { $0 != $1 }.count)

var (n, m, k) = readInts().mapToTuple()
// arrayなので反転
var An = Array(readInts().reversed())
var Bn = Array(readInts().reversed())

var res = 0
loop: while true {
    let (a, b) = (An.last, Bn.last)
    switch (a, b) {
    case let (.some(a), .some(b)):
        if a < b && a <= k {
            An.removeLast()
            res += 1; k -= a
        } else if b <= k {
            Bn.removeLast()
            res += 1; k -= b
        } else {
            break loop
        }
    case (let .some(a), nil):
        guard a <= k else { break loop }
        An.removeLast()
        res += 1; k -= a
    case (nil, let .some(b)):
        guard b <= k else { break loop }
        Bn.removeLast()
        res += 1; k -= b
    case (nil, nil): break loop
    }
}

print(res)






//print(t.difference(from: s).count)


// MARK: -----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

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

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating get {
            if let note = dictionary[argument] {
                return note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                return result
            }
        }
    }
}
