program main
	implicit none
	integer :: N,M,K,count,count_A,count_B,i
	integer, allocatable :: A(:),B(:)
		count = 0
		read(*,*) N,M,K
		count_A=N;count_B=M
		allocate(A(N),B(M))
		read(*,*) A
		read(*,*) B
		do i=1,200000
			if (K<0) then
				exit
			else
				if(count_A==0) then
					if(count_B==0) then
						exit
					else
						K = K - B(count_B)
						count_B = count_B - 1
						count = count + 1
					end if
				else if(count_B==0) then
					if(count_A==0) then
						exit
					else
						K = K - A(count_A)
						count_A = count_A - 1
						count = count + 1
					end if
				else if (A(count_A)<=B(count_B)) then
					K = K - A(count_A)
					count_A = count_A - 1
					count = count + 1
				else 
					K = K - B(count_B)
					count_B = count_B - 1
					count = count + 1
				end if
			end if
		end do
		write(*,*) count
end program main