#include<algorithm>
#include<iostream>
#include<cstdio>

using namespace std;

int a[1001],n,x,ans=0;

int main()
{
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n-1;i++)  if(a[i]<=x) x-=a[i],ans++;
	if(a[n]==x) ans++;
	cout<<ans<<endl;
	return 0;
} 