#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  vi a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (a[i] <= x) {
      x -= a[i];
      ans++;
    }
  }
  if (x > 0 && ans > 0) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}
