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