#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
long long gcd(long long x, long long y) { return (y == 0) ? x : gcd(y, x % y); }
long long lcm(long long x, long long y) { return x * y / gcd(x, y); }
bool IsPrime(int num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  long long n, x, cnt = 0;
  cin >> n >> x;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort((a).begin(), (a).end());
  while (x > 0) {
    if (x >= a[cnt]) cnt++;
    x -= a[cnt];
  }
  cout << cnt << endl;
  return 0;
}
