#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, x, ans = 0;
  vector<int> v;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    v.push_back(t);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (v[i] <= x) {
      ans++;
      x -= v[i];
    } else
      break;
  }
  cout << ans << endl;
  return 0;
}
