#include <bits/stdc++.h>
using namespace std;
int n, x, ans = 0, a[100];
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 (a[i] <= x) {
      x -= a[i];
      ans++;
    }
  }
  if (x > 0 && ans > 0) ans--;
  cout << ans << endl;
  return 0;
}
