//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let (N, M, K) = *readInt()
    var A = readInt()
    var B = readInt()
    var ruisekiA = [0]
    var ruisekiB = [0]
    for i in 0..<N {
        ruisekiA.append(ruisekiA[i] + A[i])
    }
    for i in 0..<M {
        ruisekiB.append(ruisekiB[i] + B[i])
    }
    var bestBi = 0
    var bestAi = 0
    // i = 0
    for j in (0...M).reversed() {
        if (ruisekiB[j] <= K) {
            bestBi = j
            break
        }
    }
    var ans = bestBi
    for i in 1...N {
        if (ruisekiA[i] > K) {
            break
        }
        for j in (0...bestBi).reversed() {
            if (ruisekiA[i] + ruisekiB[j] <= K) {
                ans = max(ans, i+j)
                break
            }
        }
    }
    print(ans)
}
main()
