'use strict';
let int_input_list = [];
let count = 0;

// let answer;
function main(input) {
  let state_of_books_on_the_desk = {
  	deskA:[],
    deskB:[],
  }
  
  const str_list = input.replace(/\r?\n/g," ").split(" ");

  for (let i = 0; i < str_list.length; i++){
    str_list[i] = parseInt(str_list[i])
    int_input_list.push(str_list[i])
  }
  // each books minutes
  let books_minutes = int_input_list.slice(3) 
  let initial_num_of_books_on_the_desk = int_input_list[0] + int_input_list[1]
  
  state_of_books_on_the_desk.deskA = books_minutes.slice(0, int_input_list[0])
  state_of_books_on_the_desk.deskB = books_minutes.slice(int_input_list[0])

  let max_minutes = int_input_list[2]
  let num_of_books_read = 0
  let sum_of_minutes = 0
  
  //console.log(books_minutes);
  
  for (let z=0; z < initial_num_of_books_on_the_desk; z++ ){
    //console.log('current state: ', state_of_books_on_the_desk)
    if (sum_of_minutes <= max_minutes){
    //console.log('state_of_books_on_the_desk.deskA[z]:',state_of_books_on_the_desk.deskA[z] )
    
    let current_book = 0
        if (state_of_books_on_the_desk.deskA[0] <= state_of_books_on_the_desk.deskB[0]){
            current_book = state_of_books_on_the_desk.deskA[0];
            state_of_books_on_the_desk.deskA.splice(0, 1) 
        }else{
            current_book = state_of_books_on_the_desk.deskB[0];
            state_of_books_on_the_desk.deskB.splice(0, 1) 
        }

      
        //console.log('current_book: ',current_book)
        sum_of_minutes = sum_of_minutes + current_book
        //console.log('sum_of_minutes: ', sum_of_minutes)
    
    
  		  
     
    }else{
    	break
    }
      
            
    //sum_of_minutes = sum_of_minutes + books_minutes[z];
	//console.log(z)
    num_of_books_read = z+1
  //console.log(z)

  }
  console.log(num_of_books_read)
  };

  

 
main(require('fs').readFileSync('/dev/stdin', 'utf8'))