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