#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5 + 5;
int a[106];
int main() {
  int n, k;
  cin >> n >> k;
  int sum = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (a[i] <= k) {
      ans++;
      k -= a[i];
    }
  }
  if (k > 0) ans--;
  if (ans == -1)
    cout << "0" << endl;
  else
    cout << ans << endl;
  return 0;
}
