process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", input => {
  const splitted = input.split("\n");
  const nums = splitted[0].split(" ");
  const N = Number(nums[0]);
  const M = Number(nums[1]);
  const K = Number(nums[2]);
  const Ak = createReadTime(splitted[1]);
  const Bk = splitted[2].split(" ");
  let n = N;
  let readCount = n;

  let currentReadTime = Ak[N].total;
  let a = Ak[n];
  for (const b of Bk) {
    const num = Number(b);
    if (currentReadTime + num <= K) {
      readCount++;
      currentReadTime += num;
      continue;
    }

    if (a.val >= num) {
      // 入れ替え
      n--;
      currentReadTime+= num- a.val;
      a = Ak[n];
      continue;
    }
    break;
  }
  console.log(readCount);
});

const createReadTime = (array, K) => {
  let prevTotal = 0;
  return array.split(" ").reduce((total, val, index) => {
    if (prevTotal >= K) {
      return total;
    }
    const num = Number(val);
    prevTotal += num;
    if (prevTotal > K) {
      return total;
    }
    total[index + 1] = { val: num, total: prevTotal };
    return total;
  }, {});
};
