#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  sort(A.begin(), A.end());
  int ans = 0;
  for (auto a : A) {
    if (x >= a) {
      x -= a;
      ans++;
    } else
      break;
  }
  cout << ans << endl;
}
