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

struct Indexes: Hashable, Equatable {
    let a, b: Int
    init(_ a: Int, _ b: Int) {
        self.a = a
        self.b = b
    }
}

// array[i][和] = 個数
var array = Array<Dictionary<Indexes, Int>>()

array.append(.init())
if let a = An.first, a <= k {
    array[0][Indexes(0, -1)] = k - a
}
if let b = Bn.first, b <= k {
    array[0][Indexes(-1, 0)] = k - b
}

loop: while true {
    array.append(.init())
    let i = array.endIndex - 1
    
    guard !array[i-1].isEmpty else { break loop }
    for (indexes, cost) in array[i-1] {
        if let a = An.safe(at: indexes.a + 1), a <= cost {
            array[i][Indexes(indexes.a+1, indexes.b)] = cost - a
        }
        if let b = Bn.safe(at: indexes.b + 1), b <= cost {
            array[i][Indexes(indexes.a, indexes.b+1)] = cost - b
        }
    }
}
let sub = array.prefix(while: { !$0.isEmpty })

print(sub.endIndex)



// 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()!)
    }
    
    func safe(at index: Index) -> Element? {
        self.indices.contains(index) ? self[index] : nil
    }
}

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 _read {
            if let note = dictionary[argument] {
                yield note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                yield result
            }
        }
    }
}
