#include <bits/stdc++.h>
int main() {
  int n, x;
  std::vector<int> a;
  std::cin >> n;
  std::cin >> x;
  int y;
  for (int i = 0; i < n; i++) {
    std::cin >> y;
    a.push_back(y);
  }
  std::sort(a.begin(), a.end());
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (x - a[i] >= 0) {
      sum++;
      x = x - a[i];
    } else {
      break;
    }
  }
  std::cout << sum << "\n";
  return 0;
}
