#include <bits/stdc++.h>
using namespace std;
int p[200], n, x, res = 0;
int main() {
  cin >> n >> x;
  for (int i = 1; i <= n; i++) cin >> p[i];
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; i++)
    if (x >= p[i]) {
      if (i == n) {
        if (x == p[i]) {
          res++;
          break;
        }
      }
      x -= p[i];
      res++;
    }
  cout << res << endl;
}
