#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> v(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort((v).begin(), (v).end());
  int res = 0;
  int count = 0;
  if (v[0] > x) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    count += v[i];
    if (count > x) break;
    res++;
    if (count == x) break;
  }
  if (count != x) res--;
  cout << res << endl;
}
