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