#include <bits/stdc++.h>
using namespace std;
void solve() {
  signed long long i, j, k, l, r, x, y;
  string s;
  bool exit = false;
  signed long long N;
  vector<signed long long> a;
  cin >> N >> x;
  for (i = 0; i < (N); i++) {
    signed long long input;
    cin >> input;
    a.push_back(input);
  }
  sort((a.begin()), (a.end()));
  signed long long ret = 0;
  signed long long x_ = 0;
  for (i = 0; i < (N); i++) {
    x_ += a[i];
    if (x_ == x) {
      ret += 1;
      break;
    } else if (x_ > x) {
      ret -= 1;
      break;
    } else if (N - 1 == i) {
      break;
    } else {
      ret += 1;
    }
  }
  if (ret < 0) ret = 0;
  cout << ret << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
