#include <bits/stdc++.h>
using namespace std;
long long n, s, a[111];
int main() {
  cin >> n >> s;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (s >= a[i]) {
      ans++;
      s -= a[i];
    } else {
      break;
    }
  }
  if (s) {
    ans--;
  }
  cout << max(ans, 0ll);
  return 0;
}
