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