function compareFunc(a, b) {
  return a - b;
}

function main(input) {
  let args = input.split(/\n/);
  let table1 = args[1].split(/\s/);
  let table2 = args[2].split(/\s/);
  let time = args[0].split(/\s/)[2];
  let result = 0;
  for (let i = 0;i < (table1.length + table2.length);i++) {
    if (table1[0] <= time || table2[0] <= time) {
      if (table1[0] > table2[0]) {      
        time -= table1[0];
        table1.shift();
      } else {
        time -= table2[0];
        table2.shift();
      }
      result++;
    }
  }
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));