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)! }
for i in 1..<A.count {
  A[i] += A[i-1]
}
for i in 1..<B.count {
  B[i] += B[i-1]
}
var b = B.count - 1

var maxSum = 0
for i in 0..<A.count {
  var total = A[i] + B[b]
  while b >= 0 && total > K {
    b -= 1
    if b < B.count {
      total = A[i] + B[b]
    }
  }
  if b < 0 {
    break
  }
  maxSum = max(maxSum, i + 1 + b + 1)
}
print(maxSum)
