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