#include <bits/stdc++.h>
using namespace std;
int n, a[100], x, i, c, s;
int main() {
  for (cin >> n >> x; i < n; i++) cin >> a[i], s += a[i];
  if (s == x) return cout << n, 0;
  sort(a, a + n);
  if (a[0] > x) return cout << 0, 0;
  for (i = 0; i < n; i++) {
    x -= a[i];
    if (x < 0) {
      x += a[i];
      for (int j = i + 1; j < n; j++) {
        if (x == a[j]) c++;
      }
      break;
    }
    c++;
  }
  cout << (x == 0 ? c : c - 1);
}
