#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 100;
const int INF = (1 << 12);
int main() {
  int N, x;
  int ans = 0;
  cin >> N >> x;
  vector<int> A(N);
  vector<int> S(N + 1);
  S[0] = 0;
  for (int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  for (int i = 0; i < N; ++i) S[i + 1] = S[i] + A[i];
  if (S[N] == x) {
    ans = N;
  } else if (S[N] < x) {
    ans = N - 1;
  } else {
    for (int i = 1; i < N + 1; i++) {
      if (S[i] <= x) {
        ans = i;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
