#include <bits/stdc++.h>
#define int long long
#define roop(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,x,a[100],count;
signed main(){
  cin>>n>>x;
  roop(i,n)cin>>a[i];
  sort(a,a+n);
  roop(i,n){
    if(x>a[i]){
      x-=a[i];
      count++;
    }
  }
  cout<<count<<endl;
}