#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, x, temp;
  vector<int> kids;
  int total = 0;
  int count = 0;
  cin >> N >> x;
  for (int i = 0; i < (N); i++) {
    cin >> temp;
    kids.push_back(temp);
    total += temp;
  }
  sort(kids.begin(), kids.end());
  for (int i = 0; i < (kids.size()); i++) {
    if (x >= kids[i]) {
      x = x - kids[i];
      count++;
    } else {
      break;
    }
  }
  if (x > 0 && count != 0) count--;
  cout << count << endl;
  return 0;
}
