#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  sort((a).begin(), (a).end());
  for (int i = (0); i < (n); ++i) {
    if (x >= a[i]) {
      x -= a[i];
    } else {
      cout << i << "\n";
      return 0;
    }
  }
  cout << n << "\n";
}
