import java.io.*
import java.util.*
import java.lang.Math.*

class CumSum(val A: LongArray) {
    private var csum: LongArray = LongArray(A.size + 1){0L}
    init {
        for (i in 1..A.size) {
            this.csum[i] = this.csum[i-1] + A[i-1]
        }
    }
    fun sum(L: Int, R: Int): Long {
        val r = min(R, A.size)
        val l = max(L, 0)
        if (l >= r) return 0L
        return this.csum[r] - this.csum[l]
    }
    fun sum(i: Int): Long {
        return this.sum(0,i)
    }
}

fun bsCondClOp(A: LongArray, B: LongArray, K: Long, L: Int, R: Int): Int {
    val N = A.size
    val M = B.size
    val acs = CumSum(A)
    val bcs = CumSum(B)

    fun isCondition(K: Long, m: Int): Boolean {
        for (i in 0..N) {
            val j = m-i
            if (j < 0 || M < j) continue
            if (acs.sum(i) + bcs.sum(j) <= K) return true
        }
        return false
    }
    var l = L; var r = R
    while (l < r-1) {
        val m = (l + r) / 2
        if (isCondition(K, m)) {
            l = m
        } else {
            r = m
        }
    }
    return l
}


fun main() {
    val (N,M, K) = rd.readIntArray()
    val A = rd.readLongArray()
    val B = rd.readLongArray()

    val ans = bsCondClOp(A, B, K.toLong(), 0, N+M+1)

    println(ans)
}


//val rd = debug.Reader("abc", "172", "c", "sample-2")
val rd = Reader()
fun main(args: Array<String>) {
    Thread(null, MainThread(), "mainThread", 128 * 1024 * 1024).start()
}


const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
typealias ALI = ArrayList<Int>
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
class MainThread : Runnable {
    override fun run() { main() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}
