#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int a[110];
  for (int i = 1; i <= (int)(n); i++) cin >> a[i];
  sort(a, a + n);
  int sum = 0;
  int rec = 0;
  for (int i = 1; i <= (int)(n); i++) {
    sum += a[i];
    if (sum >= x) {
      sum == x ? (rec = i + 1) : (rec = i);
      break;
    }
    if (sum < x && i == n - 1) {
      rec = i;
    }
  }
  cout << rec << endl;
}
