function main(input){
  const [l1, l2, l3] = input.split('\n');
  let [N, M, K] = l1.split(' ');
  K = Number(K);
  let aArray = l2.split(' ');
  let bArray = l3.split(' ');
  const aArrayLenOri = aArray.length;
  const bArrayLenOri = bArray.length;
  while(K > 0 && (aArray.length > 1 || bArray.length > 1)) {
    let aTime = (aArray.length === 0) ? 0 : aArray[0];
    let bTime = (bArray.length === 0) ? 0 : bArray[0];
    if (aTime <= bTime) {
      if (K >= aTime){
        K = K - aTime;
        aArray.shift();
      } else if (K >= bTime) {
        K = K - bTime;
        bArray.shift();
      }
    } else if (bTime < aTime) {
      if (K >= bTime){
        K = K - bTime;
        bArray.shift();
      } else if (K >= aTime) {
        K = K - aTime;
        aArray.shift();
      }
    }
    K = 0;
  }
  console.log((aArrayLenOri - aArray.length) + (bArrayLenOri - bArray.length));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));