#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  vector<int> v(N);
  for (int i = 0; i < N; ++i) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int c = 0;
  for (int i = 0; i < N; ++i) {
    if (M >= vec.at(i)) {
      M = M - vec.at(i);
      ++c;
    } else {
      break;
    }
  }
  if (M == 0) {
    cout << c << endl;
  } else {
    --c;
    if (c <= 0) {
      cout << 0 << endl;
    } else {
      cout << c << endl;
    }
  }
}
