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