#include <bits/stdc++.h>
using namespace std;
int N, x;
int a[110];
int main() {
  cin >> N >> x;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  sort(a, a + N);
  int counter = 0;
  while (true) {
    bool flag = false;
    x -= a[counter];
    if (x < 0 || counter == N) flag = true;
    if (flag == true) break;
    ++counter;
  }
  cout << counter << endl;
  return 0;
}
