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