#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  int a[110];
  cin >> N >> x;
  for (int i = 0; i < N; ++i) cin >> a[i];
  int c = 0;
  int i = 0;
  sort(a, a + N);
  if (x < a[0]) {
    cout << "0" << endl;
    return 0;
  }
  for (int i = 0; i < N; ++i) {
    x -= a[i];
    c++;
  }
  cout << c << endl;
  return 0;
}
