#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int x,n,m,ans=0,sum=0;
vector<int> a;
cin>>n>>x;
for(int i=0;i<n;i++){
cin>>m;
a.push_back(m);
}
sort(m.begin(),m.end());
for(int i=0;i<n;i++){
sum+=a.at(i);
if(sum<=x)ans++;
else break;
}
cout<<ans<<endl;
}
