#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const int MAX_N = 100;
int N;
int x;
int A[MAX_N];
int solve() {
  int answer = 0;
  sort(A, A + N);
  for (int i = (0); i < (N); i++) {
    x -= A[i];
    if (x == 0)
      return answer + 1;
    else if (x < 0)
      return max(answer - 1, 0);
    answer++;
  }
  return max(answer - 1, 0);
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> x;
  for (int i = (0); i < (N); i++) cin >> A[i];
  cout << solve() << "\n";
  return 0;
}
