#include<bits/stdc++.h>
using namespace std;
int n,now,a[100010],ans;
int main()
{
	scanf("%d%d",&n,&now);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i)if(a[i]<=now)++ans,now-=a[i];
	if(now&&ans==n)--ans;
	printf("%d\n",ans);
	return 0;
}