#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, k = 0, b = 0;
  int a[100];
  int x;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[i] > a[j]) std::swap(a[i], a[j]);
    }
  }
  for (int i = 0; i < n; i++) b += a[i];
  if (b == x)
    cout << n << endl;
  else if (x < b) {
    while (1) {
      if (x - a[k] >= 0) {
        x = x - a[k];
        k++;
      } else if (x - a[k] < 0)
        break;
    }
    cout << k << endl;
  } else if (b < x) {
    cout << n - 1 << endl;
  }
  return 0;
}
