#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, x, a[101], sum = 0, j = 0;
  cin >> N >> x;
  for (long long i = 0; i < (N); i++) cin >> a[i];
  sort(a, a + N);
  for (long long j = 0; sum < x; j++) {
    sum += a[j];
  }
  if (sum == x)
    cout << (j + 1) << endl;
  else
    cout << (j) << endl;
}
