#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, a[111], i, j, cnt = 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]) cnt++;
    x = x - a[i];
  }
  if (x != 0) cnt = cnt - 1;
  if (cnt < 0) cnt = 0;
  cout << cnt << endl;
  return 0;
}
