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 = parseInt(input.split('\n')[0].split(' ')[2],10);
A = input.split('\n')[1].split(' ');
B = input.split('\n')[2].split(' ');
a = 0;
b = 0;
r = 0;
while(K > 0 && a + b <= N + M - 1) {
  Aa = parseInt(A[a],10);
  Bb = parseInt(B[b],10);
  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) {
      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;
    }      
  }
}
console.log(r);
