#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e7;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  for (int i = 0; i < (n); ++i) {
    cin >> v[i];
  }
  sort((v).begin(), (v).end());
  int cc = 0;
  int i = 0;
  while (x >= v[i] && i < n) {
    x -= v[i];
    cc++;
    i++;
  }
  if (x != 0 && cc > 0) {
    cc--;
  }
  cout << cc << endl;
  return 0;
}
