#include <bits/stdc++.h>
using namespace std;
int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  int n;
  cin >> n;
  long long x;
  cin >> x;
  vector<long long> v(n);
  long long ans = 0, sum = 0;
  for (int i = (int)0; i < (int)n; i++) {
    cin >> v[i];
    sum += v[i];
  }
  if (sum == x) {
    cout << n << endl;
    return 0;
  }
  sort((v).begin(), (v).end());
  for (int i = (int)0; i < (int)n; i++) {
    if (x - v[i] >= 0) {
      x -= v[i];
      ans++;
    }
  }
  if (x > 0) ans--;
  cout << max(0LL, ans) << endl;
  return 0;
}
