#include<bits/stdc++.h>
using namespace std;
int n,x,a[10001],ans;
int main()
{
	cin>>n>>x;
	for (int i=1;i<=n;++i) cin>>a[i];
	sort(a+1,a+n+1);
	for (int i=1;i<=n;++i) if(x>=a[i]){if(i==n){if(x==a[i])ans++;break;}x-=a[i],ans++;}cout<<ans<<endl;
}