#include <bits/stdc++.h>
using namespace std;
int main() {
  int kids, sweets;
  int thresholds[101];
  cin >> kids >> sweets;
  for (int i = 0; i < kids; i++) cin >> thresholds[i];
  sort(thresholds, thresholds + kids);
  int j = 0, counter = 0;
  while (j < kids && sweets >= thresholds[j]) {
    sweets -= thresholds[j];
    counter++;
    j++;
  }
  if (sweets != 0) counter--;
  cout << counter << "\n";
}
