#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int N,x;
	int a[1001];
	cin>>N>>x;
	for(int i=0;i<N;i++)
		cin>>a[i];
	sort(a,a+N);
	vector<int> b(n);
  	for (int i = 0; i < N; i++) {
    	b[i] = min(x, a[i]);
    	x -= b[i];
  	}
  	b.back() += x;
  	int ans = 0;
  	for (int i = 0; i < N; i++) {
    	ans += (a[i] == b[i]);
  	}
  	cout << ans << '\n';	
	return 0;
}
