#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  };
  int n, x, sums = 0;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    v.push_back(c);
    sums += c;
  }
  if (sums == x)
    cout << n << endl;
  else {
    sort(v.begin(), v.end());
    int counter = 0, tests = 0;
    for (int i = 0; i < n; i++) {
      tests += v[i];
      if (x - tests >= 0) {
        counter++;
      }
    }
    if (x - tests > 0)
      cout << --counter << endl;
    else
      cout << counter << endl;
  }
}
