#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) cin >> vec[i];
  sort(vec.begin(), vec.end());
  int sum = 0;
  for (int c : vec) sum += c;
  if (sum > x) {
    int ans = 0;
    while (x - vec[ans] >= 0) {
      x -= vec[ans];
      ans++;
      if (x == 0)
        cout << ans << endl;
      else if (x - vec[ans] < 0)
        cout << ans << endl;
    }
  } else if (sum == x) {
    cout << n << endl;
  } else if (sum < x)
    cout << n - 1 << endl;
}
