#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmax(T &a, T b) {
  a = max(a, b);
}
template <typename T>
void chmin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
void chadd(T &a, T b) {
  a = a + b;
}
long long int dx[] = {0, 0, 1, -1};
long long int dy[] = {1, -1, 0, 0};
const long long INF = 1001001001001001LL;
const long long MOD = 1000000007LL;
long long int A[200];
signed main() {
  long long int N, X;
  cin >> N >> X;
  for (long long int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A, A + N);
  long long int ans = 0, rest = X;
  for (long long int i = 0; i < N; i++) {
    if (rest >= A[i]) {
      ans++;
      rest -= A[i];
    }
  }
  cout << max(0LL, ans - (rest > 0)) << endl;
  return 0;
}
