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

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

var count = 0 

var a = 0
var b = 0


while K > 0 && (a < A.count || b < B.count) {
  if a >= A.count {
    K -= B[b]
    b += 1
  } else if b >= B.count {
    K -= A[a]
    a += 1
  } else if A[a] < B[b] {
    K -= A[a]
    a += 1
  } else {
    K -= B[b]
    b += 1
  }
  if K >= 0 {
    count += 1
  }
}
print(count)