#include <bits/stdc++.h>
using namespace std;
int gcd(int one, int two) {
  while (one != 0 && two != 0) {
    if (one > two) {
      one = one % two;
    } else {
      two = two % one;
    }
  }
  return std::max(one, two);
}
int main() {
  using namespace std;
  int a = 0, b = 0, c = 1, d = 0, e = 0, min = 0, ma = 0, ans = 0, count = 0,
      nagax = 0, nagay = 0, size = 0;
  int sa[10000];
  std::string str[150], strs;
  cin >> a >> b;
  for (int i = 0; i < a; i++) {
    cin >> sa[i];
  }
  std::sort(sa, sa + a);
  while (b > 0) {
    if (b >= sa[d]) {
      b -= sa[d];
    } else {
      break;
    }
    d++;
  }
  cout << d << endl;
}
