#include <bits/stdc++.h>
using namespace std;
int n, A[105], m;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> A[i];
  sort(A + 1, A + n + 1);
  int Ans;
  Ans = 0;
  for (int i = 1; i <= n; ++i)
    if (m - A[i] >= 0) Ans++, m -= A[i];
  cout << Ans << endl;
  return 0;
}
