#include <bits/stdc++.h>
int main() {
  int n, x;
  std::cin >> n >> x;
  std::vector<int> a;
  for (int i = 0; i < n; i++) {
    int d;
    std::cin >> d;
    a.push_back(d);
  }
  std::sort(a.begin(), a.end());
  int count = 0;
  for (auto v : a) {
    if (v > x) break;
    x -= v;
    count++;
  }
  std::cout << count << std::endl;
}
