#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> child(n);
  for (int i = 0; i < n; i++) {
    cin >> child[i];
  }
  sort(child.begin(), child.end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (x >= child[i]) {
      x -= child[i];
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
