#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
using namespace std;
const long long N = 2e5 + 100;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long long long n, x;
  cin >> n >> x;
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    long long long long z;
    cin >> z;
    a.push_back(z);
  }
  sort(a.begin(), a.end());
  long long long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (x >= a[i]) {
      ans++;
      x -= a[i];
    }
  }
  if (x)
    return cout << max((long long long long)0, ans - 1) << '\n', 0;
  else
    cout << ans << '\n';
}
