fun main() {
    val (_, _, k) = readInts().map { it.toLong() }
    val a = readInts().map { it.toLong() }.toMutableList()
    val b = readInts().map { it.toLong() }.toMutableList()

    a.forEachIndexed { index, _ -> if (index > 0) a[index] += a[index - 1] }
    b.forEachIndexed { index, _ -> if (index > 0) b[index] += b[index - 1] }

    fun lowerBound(element: Long, list: List<Long>): Int {
        val index = list.binarySearch(element)
        if (index >= 0) return index
        return -(index + 1) - 1
    }

    var maxRead = lowerBound(k, b) + 1

    a.forEachIndexed { index, i ->
        maxRead = if (i <= k) {
//            println("a curr: $i search: ${k - i} b insertion: ${lowerBound(k - i, b)}")
            maxOf(maxRead, index + 1 + lowerBound(k - i, b) + 1)
        } else maxOf(0, maxRead)
    }

    println(maxRead)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
//private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }
