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