#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] <= x) {
      ans++;
    } else {
      break;
    }
    x -= a[i];
  }
  if (x > 0)
    cout << ans - 1 << endl;
  else
    cout << ans << endl;
  return 0;
}
