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