#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using pl = pair<ll, ll>;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll INF = 1e9 + 9, LINF = 1e18;
int main(int argc, char* argv[]) {
  int n, x, ans = 0;
  cin >> n >> x;
  int a[n];
  for (ll i = 0; i < (n); ++i) cin >> a[i];
  sort(a, a + n);
  for (ll i = 0; i < (n); ++i) {
    x -= a[i];
    if (i == n - 1 && x != 0) break;
    if (x >= 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
