#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int sum = accumulate(a.begin(), a.end(), 0);
  if (sum < x) {
    cout << n - 1 << endl;
    exit(0);
  }
  if (sum == x) {
    cout << n << endl;
    exit(0);
  }
  int i = 0;
  int ans = 0;
  bool flag = false;
  while (ans <= x) {
    ans += a.at(i);
    i++;
    if (ans > x) {
      flag = true;
    }
  }
  if (flag) {
    cout << i - 1 << endl;
  } else {
    cout << i << endl;
  }
}
