#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int a[1111], b[1111], n, p, ans = 0;
  memset(a, 0, sizeof(a)), memset(b, 0, sizeof(b));
  cin >> n >> p;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (i + 1 == n)
      b[i] = p;
    else {
      if (a[i] <= p) b[i] = a[i];
      p = p - a[i];
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i]) ans++;
  }
  cout << ans;
  return 0;
}
