#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  int a[n];
  for(int i=0; i < n; i++){
  	cin >> a[i]
  }
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n; i++){
  if(i == n - 1){
    //mこ割り振る
    if(m == a[i]){
      ans++;
    }
    break;
  }
  if( m >= a[i]){
  	m = m - a[i];
    ans++;
  }
}
     cout << ans << endl;
}