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