#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  std::vector<int> a;
  for (int i = 0; i < n; i++) {
    int m1;
    cin >> m1;
    a.push_back(m1);
  }
  std::sort(a.begin(), a.end());
  int result = 0;
  for (int i = 0; i < n; i++) {
    int give = a[i];
    if (x - give >= 0) {
      result++;
      x -= give;
    } else {
      break;
    }
  }
  if (x > 0 && result > 1) result--;
  cout << result << endl;
  return 0;
}
