let input = readLine()!.split(separator: " ")
let N = Int(input[0])!
let M = Int(input[1])!
var K = Int(input[2])!

var A = readLine()!.split(separator: " ").map { Int($0)! }
var B = readLine()!.split(separator: " ").map { Int($0)! }

var a: [Int] = .init(repeating: 0, count: N + 1)
var b: [Int] = .init(repeating: 0, count: M + 1)

for i in 1...N {
  a[i] += A[i-1] + a[i-1]
}
for i in 1...M {
  b[i] += B[i-1] + b[i-1]
}
var maxSum = 0
var j = M
for i in 0...N {
  if A[i] > K {
    break
  }
  while A[i] + B[j] > K {
    j -= 1
  }
  maxSum = max(maxSum, i + j)
}
print(maxSum)