#include<bits/stdc++.h>
using namespace std;

#define N 105

int n,A[N],m;

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	cin>>A[i];
	sort(A+1,A+n+1);
	int Ans;
	Ans=0;
	for(int i=1;i<=n;++i)
	if(m-A[i]>=0)
	Ans++,m-=A[i];
	if(m>0&&Ans==n)
	Ans--;
	cout<<Ans<<endl;
	return 0;
}