#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> needs(N);
  for (int i = 0; i < N; i++) cin >> needs.at(i);
  sort(needs.begin(), needs.end());
  int answer = 0;
  for (int y : needs) {
    if (x < y) break;
    x -= y;
    answer++;
  }
  cout << answer << endl;
  return 0;
}
