#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 1;
const long long MOD = 1e9 + 7;
const long double PI = 3.14159265358979323846264338;
void solve() {
  long long n, x;
  cin >> n >> x;
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    long long y;
    cin >> y;
    a.push_back(y);
  }
  sort(a.begin(), a.end());
  bool run = true;
  long long i = 0;
  while (run && i < n) {
    if (a[i] <= x) {
      x -= a[i];
      i++;
    } else {
      run = false;
    }
  }
  cout << i;
}
signed main() {
  long long t = 1;
  while (t--) solve();
  return 0;
}
