#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int n, x;
  while (cin >> n >> x) {
    int aa[n + 1];
    int i;
    for (i = 0; i < n; i++) {
      cin >> aa[i];
    }
    sort(aa, aa + n);
    int sum = 0;
    for (i = 0; i < n; i++) {
      if (x >= aa[i]) {
        x -= aa[i];
        sum += 1;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
