#include <bits/stdc++.h>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
struct Problem {
  void Solve() {
    UL N;
    cin >> N;
    UL X;
    cin >> X;
    UL A[100];
    for (UL i = 0; i < (N); i++) cin >> A[i];
    sort(A, A + N);
    UL ans = 0;
    for (UL i = 0; i < (N); i++) {
      if (A[i] <= X) {
        X -= A[i];
        ans++;
      }
    }
    if (X != 0) ans--;
    cout << ans << endl;
  }
  Problem();
};
int main() {
  unique_ptr<Problem> p(new Problem());
  p->Solve();
  return 0;
}
Problem::Problem() { cout << fixed << setprecision(10); }
