#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, total = 0;
  vector<int> a;
  int tmp;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    total += tmp;
    a.push_back(tmp);
  }
  if (total == x) {
    cout << n << endl;
    return 0;
  } else if (total < x) {
    cout << n - 1 << endl;
    return 0;
  } else {
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
      if (x >= a[i]) {
        x -= a[i];
      } else {
        cout << i << endl;
        return 0;
      }
    }
    cout << "okasii";
  }
}
