#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x;
  cin>>N>>x;
  int X;
  priority_queue<<int>,vector<int>,greater<int> > A;
  for(int i=0;i<N;i++){
    cin>>X;
    A.push(X);
  }
  int count=0;
  while(N>0){
    N-=A.top();
    A.pop();
    count++;
  }
  cout>>count;
}

  
    
  
