#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-9;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
  int n;
  cin >> n;
  long long x;
  cin >> x;
  vector<long long> num(n);
  for (int(i) = 0; (i) < (int)(n); i++) {
    cin >> num.at(i);
  }
  sort((num).begin(), (num).end());
  int cnt = 0;
  int i = 0;
  while (x > 0) {
    if (x >= num.at(i)) {
      x -= num.at(i);
      i++;
      cnt++;
    } else {
      break;
    }
    if (i == n - 1) {
      break;
    }
  }
  cout << cnt << endl;
  return 0;
}
