#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,x;
int a[N];
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&&x>=0;x-=a[i++])
		if(x<a[i]||i==n+1)
			printf("%d\n",i-1-(i==n+1&&x>0));
	return 0;
}