program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,m,k,i, cnt=0, time=0, ia=1, ib=1
    integer(int64), allocatable:: a(:), b(:)

    read*, n, m, k
    allocate(a(n+1), b(m+1), source=20000000000_8)
    read*, a(1:n)
    read*, b(1:m)

    do while(time <= k .and. ia <= n+1 .and. ib <= m+1)
        if (a(ia) <= b(ib)) then
            cnt=cnt+1
            time=time+a(ia)
            ia=ia+1
        else
            cnt=cnt+1
            time=time+b(ib)
            ib=ib+1
        end if
    end do

    if (time > k) cnt=min(cnt-1,0)
    print'(i0)', cnt
end program main