#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,x,i,ans = 0;cin >> n >> x;
  int a[n];
  for(i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  for(i=0;i<n;i++){
    if(x >= a[i]){
      ans++;x -= a[i];
    } else break;
  }
  if(ans == n && x > 0) ans--;
  cout << ans << endl;
}