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