#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int N, x, ans, sum;
int main() {
  cin >> N;
  cin >> x;
  ans = 0;
  sum = 0;
  int a[N];
  for (int i = 0; i < (int)(N); i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum == x) {
    cout << N << endl;
    return 0;
  } else if (sum < x) {
    cout << N - 1 << endl;
    return 0;
  }
  sort(a, a + N);
  int i = 0;
  while (x > 0) {
    x -= a[i];
    i++;
    ans++;
  }
  if (x < 0) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}
