#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int n, x;
  cin >> n >> x;
  int a[n];
  int ans = 0;
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  rep(i, n) {
    if (x <= 0) break;
    x -= a[i];
    ans++;
  }
  cout << ans << endl;
}