process.stdin.resume();
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ！！

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  const [N,M,K] = lines[0].split(" ").map(v=>v-0);
  const alist = lines[1].split(" ").map(v=>v-0);
  const blist = lines[2].split(" ").map(v=>v-0);
  let ans = 0;
  let sum = 0;
  for(let i=0;i<N+M;i++){
      let pp;
      if(alist.length>0 && alist[0]<=blist[0]){
          pp = alist.splice(0,1)[0];
      }else if(blist.length>0){
          pp = blist.splice(0,1)[0];
      }else{
          break;
      }
      sum+=pp;
      if(sum>K) break;
      ans++;
  }
  console.log(ans);
});
