#include <bits/stdc++.h>
using namespace std;
const int SIZE = 2e5 + 4;
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input() {}
void swap(int& a, int& b) {
  int t = a;
  a = b;
  b = t;
}
void solveTest() {
  long long n, x;
  cin >> n >> x;
  vector<long long> v(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    sum += v[i];
  }
  if (sum == x) {
    cout << n << endl;
    return;
  }
  if (x > sum) {
    cout << n - 1 << endl;
    return;
  }
  sort(v.begin(), v.end());
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] <= x) {
      cnt++;
      x -= v[i];
    }
  }
  if (x > 0)
    cout << n - 1 << endl;
  else
    cout << cnt << endl;
  return;
}
int main() {
  fastio();
  int t = 1;
  while (t--) {
    solveTest();
  }
  return 0;
}
