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

console.log(max)