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