#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  sort(begin(a), end(a));
  int cnt = 0;
  for (int i = 0; i < (n); i++) {
    if (x <= 0 || x < a[0]) break;
    x -= a[i];
    cnt++;
    if (i == n - 1 && x > 0) cnt--;
  }
  cout << cnt << endl;
}
