#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  long N, X, cnt = 0, sum = 0;
  cin >> N >> X;
  vector<int> a(N, 0);
  for (size_t i = 0; i < N; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }
  if (sum == X) {
    cout << N << endl;
  } else if (sum > X) {
    sort(a.begin(), a.end());
    int i = 0;
    while (X >= a.at(i)) {
      X -= a.at(i);
      cnt++;
    }
    cout << cnt << endl;
  } else if (sum < X) {
    cout << N - 1 << endl;
  }
  return 0;
}
