program main
  implicit integer(a-z)
  allocatable::a(:)
  allocatable::sort(:)

  read(*,*)n,have
  allocate(a(n))
  allocate(sort(n))
  read(*,*)(a(i),i=1,n)

  do j=1,n
     min=10**9+1
     do i=1,n-j+1
        if(a(i).lt.min)then
           min=a(i)
           sort(i)=min
           rec=i
        end if
        tmp=a(i)
        a(i)=a(n-j+1)
        a(n-j+1)=tmp
     end do
  end do

  do i=1,n
     if(sum(a(1:i)).gt.have)then
        exit
     end if
  end do
  
  write(*,*)i-1

end program main
