#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  if (a > b)
    return gcd(a % b, b);
  else
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long ans = 0, max = 0;
  while (max < x && ans != n) {
    max += a[ans++];
  }
  if (ans == n && max != x) ans--;
  cout << ans << endl;
}
