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