const main = (input) => {
  input = input.trim().split('\n')
  const [n, m, k] = input[0].split(' ').map(Number)
  const a = input[1].split(' ').map(Number)
  const b = input[2].split(' ').map(Number)

  let ans = 0

  const addB = (sum, count) => {
    for (let i=0; i<b.length; i++) {
      if (sum + b[i] <= k) {
        sum += b[i]
        count++
      }
      else break
    }

    return count
  }


  let a_sum = 0
  let a_count = 0
  const r = addB(a_sum, a_count)
  ans = Math.max(ans, r)

  for (let i=0; i<a.length; i++) {
    if (a_sum + a[i] <= k) {
      a_sum += a[i]
      a_count++

      const r = addB(a_sum, a_count)
      ans = Math.max(ans, r)
    }
    else break
  }

  return console.log(ans)
}

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