#include <bits/stdc++.h>
using namespace std;
int n, x, a[109];
int main() {
  cin >> n >> x;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  bool eq = (sum == x);
  sort(a, a + n);
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (x >= a[i]) {
      x -= a[i];
      ++cnt;
    }
  }
  cout << (cnt != n && !eq ? n - 1 : cnt) << endl;
  return 0;
}
