#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];
  int y = x;
  sort(a, a + n);
  i = 0;
  if (a[0] > x) return cout << 0, 0;
  while (x > 0 && c < n) x -= a[i], i++, c++;
  cout << (y > s ? c - 1 : c);
}
