#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = (int)(0); i < (int)(n); ++i) cin >> a[i];
  sort((a).begin(), (a).end());
  int ans = 0;
  for (int i = (int)(0); i < (int)(n); ++i) {
    if (x < a[i]) break;
    x -= a[i];
    ans++;
  }
  cout << ans << endl;
}
