#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100+5;
int n,x,a[maxn];
int main(){
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int i,ans=0;
	for(i=1;i<=n;i++)
	if(x>=a[i])x-=a[i],ans++;else break;
	if(i>n&&x)ans--;
	printf("%d",ans);
	return 0;
}