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