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