#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  vector<int> A(n);
  for (int i = 0; i < (n); ++i) cin >> A.at(i);
  sort(A.begin(), A.end());
  for (int i = 0; i < (n); ++i) {
    x -= A.at(i);
    if (x == 0) {
      cout << i + 1 << endl;
      return (0);
    } else if (x < A.at(i)) {
      cout << i << endl;
      return (0);
    }
  }
  cout << n - 1 << endl;
}
