#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
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());
  if (a[0] > x) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  int i = 0;
  while (x > 0) {
    x -= a[i];
    i++;
    if (i == n) {
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}
