#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;
  cin >> N >> x;
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  int i;
  for (i = 0; i < N; i++) {
    if (x < A[i]) {
      break;
    } else {
      x -= A[i];
    }
  }
  if (x > 0 && i > 0) i--;
  cout << i << endl;
  return 0;
}
