const main = (input) => {
  input = input.trim().split('\n')
  const [N, M, K] = input[0].split(' ').map(Number)
  const booksA = input[1].split(' ').map(Number)
  const booksB = input[2].split(' ').map(Number)

  const r = (count, time, A, B) => {
    if (time > K) return null

    ans = Math.max(count, ans)

    if (A.length) {
      const [top, ...rest] = A
      r(count+1, time+top, rest, B)
    }

    if (B.length) {
      const [top, ...rest] = B
      r(count+1, time+top, A, rest)
    }
  }

  let ans = 0
  r(0, 0, booksA, booksB)

  return console.log(ans)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))