#include<cstdio>
#include<algorithm>
#define MN 100001
using namespace std;

int t,n,ans=0,b,a[MN],bo;
int main(){
	scanf("%d%d",&n,&b);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for (int i=1;i<n;i++)
	if (b>=a[i]) b-=a[i],ans++;
	if (b==a[n]) ans++;
	printf("%d\n",ans);
} 