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