#include <bits/stdc++.h>
using namespace std;
struct Solver {
  Solver() {
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  }
  void solve() {
    int N, x;
    cin >> N >> x;
    int sum = 0;
    vector<int> a(N);
    for (auto& v : a) {
      cin >> v;
      sum += v;
    }
    if (sum == x) {
      cout << N << endl;
      return;
    }
    sort(a.begin(), a.end());
    int s = 0;
    int k = N - 1;
    for (int i = 0; i < N; ++i) {
      s += a[i];
      if (s > x) {
        k = i;
        break;
      }
    }
    cout << k << endl;
  }
};
int main() {
  Solver().solve();
  return 0;
}
