#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
	int total, x, tmp;
	cin >> total >> x;
	vector<int> number(total);
	for (int i = 0; i < total; i++) {
		cin >> number[i];
	}
	sort(number.begin(), number.end());
	/*for (int i = 0; i < total; ++i) {
		for (int j = i + 1; j < total; ++j) {
			if (number[i] > number[j]) {
				tmp = number[i];
				number[i] = number[j];
				number[j] = tmp;
			}
		}
	}*/

	int counter = 0;
	for (int i = 0; i < total; i++) {
		if (x - number[i] >= 0) {
			counter++;
			if (x - number > 0 && i == total - 1) {
				counter--
			}
			else if (x - number == 0 && i = total - 1{
				break;
			}
			else{
				x = x - number[i];
		}
	}
		else if (x - number[i] < 0) {
		counter = counter;
			if (counter == 0) {
				counter = 0;
					
			}
		break;
		}
}

cout << counter << endl;
return 0;


}