#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int n, x, ans, okashi;
int main() {
  cin >> n >> x;
  vector<int> a(n);
  okashi = 0;
  for (int i = 0; i < (n); ++i) {
    cin >> a.at(i);
    okashi += a.at(i);
  }
  sort(a.begin(), a.end());
  ans = 0;
  if (okashi >= x) {
    for (int i = 0; i < (n); ++i) {
      if (x >= a.at(i)) {
        x -= a.at(i);
        ans++;
      } else {
        break;
      }
    }
  } else {
    ans = n - 1;
  }
  cout << ans << endl;
  return 0;
}
