import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val (n,m,k) = readints()
    val a = readlongs().toLongArray()
    val b = readlongs().toLongArray()
    for(i in 0 until n - 1){
        a[i + 1] += a[i]
    }
    for(i in 0 until m - 1){
        b[i + 1] += b[i]
    }
    var ans = 0
    for(i in 0 until n){
        if(a[i] <= k) ans = i + 1
    }
    for(i in 0 until m){
        if(b[i] > k) break
        var l = -1
        var r = n
        while(Math.abs(r - l) > 1){
            val mid = (r + l) / 2
            if(a[mid] + b[i] <= k) l = mid
            else r = mid
        }
        ans = Math.max(ans, i + 1 + l + 1)
    }
    println(ans)
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}