#include <bits/stdc++.h>
using namespace std;
static const int INF = 1e+9 + 7;
static const long long INFL = 1e+18 + 7;
long long n, m, l;
string s, t;
long long d[200010], dp[300][300];
char field[200][200];
vector<string> split(string str, string delim) {
  vector<string> result;
  int cut;
  while ((cut = str.find_first_of(delim)) != str.npos) {
    if (cut > 0) {
      result.push_back(str.substr(0, cut));
    }
    str = str.substr(cut + 1);
  }
  if (str.length() > 0) result.push_back(str);
  return result;
}
int main() {
  vector<int> vec;
  long long ans = 0;
  cin >> n >> m;
  for (long long i = (0); i < (n); i++) {
    cin >> l;
    vec.push_back(l);
  }
  sort((vec).begin(), (vec).end());
  for (long long i = (0); i < (vec.size()); i++) {
    if (m >= vec[i]) {
      m -= vec[i];
      ans++;
    }
  }
  if (m > 0 && ans > 0) ans--;
  cout << (ans) << "\n";
  return 0;
}
