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