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