#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
inline int read() {
  register char c_;
  register int _, __;
  for (_ = 0, __ = 1, c_ = getchar(); !isdigit(c_); c_ = getchar())
    if (c_ == '-') __ = -1;
  for (; isdigit(c_); c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
  return _ * __;
}
int n, first, a[105], cnt;
int main() {
  n = read(), first = read();
  for (register int i = (1), i_end_ = (n); i <= i_end_; ++i) a[i] = read();
  sort(a + 1, a + 1 + n);
  for (register int i = (1), i_end_ = (n); i <= i_end_; ++i) {
    if (first >= a[i])
      ++cnt, first -= a[i];
    else
      break;
  }
  printf("%d\n", cnt);
  return 0;
}
