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