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