#include <bits/stdc++.h>
using namespace std;
long long n, k, ar[100004], x;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  sort(ar, ar + n);
  long long cur = 0;
  while (cur < n && x >= ar[cur]) {
    x -= ar[cur];
    cur++;
  }
  cout << cur << endl;
  return 0;
}
