#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int a[N];
int n, x, ans;
int main() {
  cin >> n >> x;
  for (int i = 0; (i) < (n); ++i) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; ++i) {
    if (x - a[i] >= 0) {
      ans++;
      x -= a[i];
    }
  }
  if (x > 0) {
    ans--;
  }
  cout << max(ans, 0) << endl;
  return 0;
}
