inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
N = l.shift() * 1
M = l.shift() * 1 
K = BigInt(l.shift()) 
A = inp.shift().split(' ')
B = inp.shift().split(' ')
k = 0n
max = 0
for (i=0; i<N; i++) {
    max = i
    k += BigInt(A[i])
    if (k > K) {
       k -= BigInt(A[i])
       break;
    }
}
i-- 
for (j=0; j<M; j++) {
    while(k + BigInt(B[j]) > K && i >= 0) {
        k -= BigInt(A[i])
        i--
    }
    k += BigInt(B[j])
    if (k > K) {
        continue;
    }
    if (max < i + 1 + j + 1) {
        max = i + 1 + j + 1
    }
}

console.log(max)