#include <bits/stdc++.h>
using namespace std;
int n, a[100], x, i, c, s;
int main() {
  for (cin >> n >> x; i < n; i++) cin >> a[i], s += a[i];
  if (s == x) return cout << n, 0;
  sort(a, a + n);
  i = 0;
  while (a[i] <= x) c++, i++, x -= a[i];
  cout << c;
}
