import java.lang.Integer.max

fun main() {
    val (N, M, K) = nextIntList()
    val aList = nextIntList()
    val bList = nextIntList()

    val aSumList = sizedArray(N + 1, 0L)
    aList.forEachIndexed { index, i ->
        aSumList[index + 1] = aSumList[index] + i
    }
    val bSumList = sizedArray(M + 1, 0L)
    bList.forEachIndexed { index, i ->
        bSumList[index + 1] = bSumList[index] + i
    }

    var res = 0
    var bIndex = M
    run {
        aSumList.forEachIndexed { index, a ->
            if (a > K) return@run
            while (a + bSumList[bIndex] > K) {
                bIndex--
            }
            res = max(res, index + bIndex)
        }
    }
    println(res)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}