#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v;
  int n, x, inp;
  scanf("%d %d", &n, &x);
  while (n--) {
    scanf("%d", &inp);
    v.push_back(inp);
  }
  int ans = 0;
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
    if (v[i] > x) break;
    ans++;
    x -= v[i];
  }
  if (x && ans) ans--;
  cout << ans << '\n';
  return 0;
}
