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