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