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