import scala.math

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var n , m , k = sc.nextInt()
  var a:List[Int] = List.fill(n)(sc.nextInt())
  var b:List[Int] = List.fill(m)(sc.nextInt())
  if (a.sum + b.sum <= k) {println(a.length + b.length);sys.exit()}
  a :+= 1000000000
  b :+= 1000000000
  var ans:BigInt = 0
  var co = 0
  while (ans + math.min(a(0),b(0)) < k & co < a.length + b.length){
    ans = ans + math.min(a(0),b(0))
    if (a(0) > b(0)) {
      b = b.drop(1)
    } else {
      a = a.drop(1)
    }
    co += 1
  }
  println(co)
}
