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