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