#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=105;
int a[N],n,x;
int main()
{
cin >>n>>x;
for(int i=1;i<=n;i++)cin >>a[i];
sort(a+1,a+1+n);
int ans=0;
for(int i=1;i<=n;i++)
	if(x>=a[i])
		ans++,x-=a[i];
if(x&&ans==n)ans--;
cout <<ans;
return 0;
}
