#include <bits/stdc++.h>
using namespace std;
int n, x, a[110];
long long qs[110];
long long demand = 0;
int main() {
  cin >> n >> x;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    demand += a[i];
  }
  if (demand < x)
    cout << n - 1;
  else if (demand == x)
    cout << n;
  else {
    sort(a, a + n);
    qs[0] = a[0];
    for (int i = 1; i < n; ++i) qs[i] = qs[i - 1] + a[i];
    for (int i = 0; i < n; ++i) {
      if (qs[i] < x)
        continue;
      else {
        cout << i;
        break;
      }
    }
  }
  return 0;
}
