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