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