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