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