function*stdinIter(){const t=require("fs").readFileSync("/dev/stdin","utf-8").trim().split(/\n|\s/);yield*t}function readMany(t,e){const i=e||this.iter||(this.iter=stdinIter()),n=[];for(let e=0;e<t;e+=1)n.push(i.next().value);return n};

(() => {
    const [ n, m, k ] = readMany(3).map(it => parseInt(it))
    const a = readMany(n).map(it => parseInt(it))
    const b = readMany(m).map(it => parseInt(it))

    let time = 0
    let books = 0
    while (true) {
        if (a.length == 0 && b.length == 0) {
            break
        } else if (a.length == 0) {
            time += b.shift()
        } else if (b.length == 0) {
            time += a.shift
        } else if (a[0] > b[0]) {
            time += b.shift()
        } else {
            time += a.shift()
        }

        if (time > k) {
            break
        } else {
            books += 1
        }
    }

    console.log(books)
})()
