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