#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  int N, x;
  cin >> N >> x;
  set<long long> Set;
  for (int n = 0; n < N; ++n) {
    long long a;
    cin >> a;
    Set.insert(a);
  }
  long long Sum = 0;
  for (auto tmp : Set) {
    Sum += tmp;
  }
  if (x == Sum) {
    cout << N << endl;
    return 0;
  } else if (x > Sum) {
    cout << N - 1 << endl;
    return 0;
  }
  int Res = 0;
  for (auto tmp : Set) {
    if (x >= tmp) {
      x -= tmp;
      ++Res;
    }
  }
  cout << Res << endl;
  return 0;
}
