function main(input) {
	const args = input.split('\n')
    const l1 = args[0].split(' ')
    const bookA = args[1].split(' ')
    const bookB = args[2].split(' ')
    let deskA = parseInt(l1[0])
    let deskB = parseInt(l1[1])
    const limit = parseInt(l1[2])
    
    let cnt = 0
    let sum = 0
    
    while(true) {
      	if (
          (sum+parseInt(bookA[0]) >= limit) && 
          (sum+parseInt(bookB[0]) >= limit)
        ) {
        	break
        }
      	const bAlen = bookA.length
        const bBlen = bookB.length
      	
        if (bAlen > 0 && bBlen > 0) {
          
          if (bookA[0] > bookB[0]) {
              sum += parseInt(bookA.shift())
          } else {
              sum += parseInt(bookB.shift())
          }
        }
        else {
          if (bAlen === 0 && bBlen === 0) break

          if (bAlen === 0 && bBlen > 0) {
              sum += parseInt(bookB.shift())
          }

          if (bBlen === 0 && bAlen > 0) {
              sum += parseInt(bookA.shift())
          }
        }
      	cnt++
    }
    
  	console.log(cnt)
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));