#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, amount, chil[110], sum = 0, happy = 0;
  cin >> N >> amount;
  for (int i = 0; i < N; i++) cin >> chil[i];
  sort(chil, chil + N);
  for (int i = 0; i < N; i++) {
    sum += chil[i];
    if (sum > amount) {
      happy = i;
      break;
    } else
      happy = N;
  }
  cout << happy << endl;
  return 0;
}
