fs = require('fs');
input = fs.readFileSync('/dev/stdin','utf8');
N = parseInt(input.split('\n')[0].split(' ')[0],10);
M = parseInt(input.split('\n')[0].split(' ')[1],10);
K = BigInt(input.split('\n')[0].split(' ')[2]);
A = input.split('\n')[1].split(' ');
B = input.split('\n')[2].split(' ');
a = 0; b = 0; r = 0;
while(K > 0 && (a < N || b < M)) {
  Aa = BigInt(A[a]);
  Bb = BigInt(B[b]);
  if(a < N && b < M) {
    if(Aa <= Bb) {
      if(K - Aa >= 0) {
        K = K - Aa; a = a + 1; r = r + 1;
//        console.log('a' + a + ' ' + K);
      } else K = 0;
    } else {
      if(K - Bb >= 0) {
        K = K - Bb; b = b + 1; r = r + 1;
//        console.log('b' + b + ' ' + K);
      } else K = 0;
    }
  } else if(b == M && K - Aa >= 0) {
    K = K - Aa; a = a + 1; r = r + 1;
//    console.log('a' + a + ' ' + K);
  } else if(a == N && K - Bb >= 0) {
    K = K - Bb; b = b + 1; r = r + 1;
//    console.log('b' + b + ' ' + K);
  } else K = 0;
}
console.log(r);
