#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln = '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> A(n);
  for (int i = 0; i < (n); i++) cin >> A[i];
  sort((A).begin(), (A).end());
  int cnt = 0;
  for (int i = 0; i < (n); i++) {
    if (x < A[i]) break;
    x -= A[i];
    cnt++;
  }
  if (x > 0) cnt--;
  cout << cnt << ln;
}
