#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, n, s, b[114514] = {}, ans = 0;
  cin >> n >> s;
  for (int i = 0; i < n; i++) cin >> b[i];
  sort(b, b + n);
  for (int i = 0; i < n; i++) {
    if (s < b[i])
      break;
    else {
      s -= b[i];
      ans++;
    }
  }
  cout << ans << endl;
}
