#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 100;
long long n, x;
int main(int argc, char const *argv[]) {
  cin >> n >> x;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long ans = 0;
  if (x < a[0])
    ans = 0;
  else {
    long long lastidx = 0;
    for (long long i = 0; i < n; i++) {
      lastidx = i;
      if (x < a[i])
        break;
      else {
        x -= a[i];
        ans++;
      }
    }
    if (lastidx + 1 == n && x > 0) ans--;
  }
  cout << ans << endl;
  return 0;
}
