#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int a[110];
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  long sum = 0;
  int j = 0;
  if (x >= a[0]) {
    while (true) {
      sum += a[j];
      if (sum == x)
        break;
      else if (sum > x) {
        j -= 2;
        break;
      } else
        ++j;
    }
    cout << j + 1 << endl;
  } else
    cout << "0" << endl;
}
