#include <bits/stdc++.h>
using namespace std;
const int Nmax = 101;
int n, a[Nmax], ps[Nmax], x;
int main() {
  cin >> n >> x;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) {
    ps[i] = ps[i - 1] + a[i];
  }
  if (x > ps[n]) {
    cout << n - 1;
    return 0;
  }
  cout << upper_bound(ps, ps + n + 1, x) - ps - 1;
}
