#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
int dx4[4] = {1, 0, -1, 0}, dy4[4] = {0, 1, 0, -1};
vector<ll> v[510000];
int main() {
  int n, x, ans = 0;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort((a).begin(), (a).end());
  for (int i = 0; i < n; i++) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    } else
      break;
  }
  cout << ans << endl;
  return 0;
}
