#include <bits/stdc++.h>
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;
int main() {
  int n, x;
  std::cin >> n >> x;
  vt<int> a(n);
  for (int i = 0; i < (int)n; i++) std::cin >> a[i];
  sort(a.begin(), a.end());
  int cnt = 0;
  for (int i = 0; i < (int)n; i++) {
    if (x >= a[i]) {
      x -= a[i];
      cnt++;
    } else
      break;
  }
  std::cout << cnt << '\n';
  return 0;
}
