#include<bits/stdc++.h>
using namespace std;
const int N=111;
int a[N],n,s;
int main(){
#ifdef flukehn
	freopen("g.in","r",stdin);
#endif
	cin>>n>>s;
	int i;
	for(i=1;i<=n;++i)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(i=1;i<=n;++i)
		if(a[i]>s)break;
		else s-=a[i];
	printf("%d\n",i-1-(i>n&&s>0));
}