#include<cstdio>
#include<algorithm>
using namespace std;
int a[105];
int main(){
	int n,x,i,sum=0;
	scanf("%d%d",&n,&x);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	sort(a,a+n);
	for(i=0;i<n;i++)if(sum+a[i]>x)break;
	else sum+=a[i];
	if(i==n&&sum!=x)i--;
	printf("%d\n",i);
	return 0;
}