#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, x;
  cin >> N >> x;
  vector<int> a;
  int num;
  for (int _ = (0); _ < (N); ++_) {
    cin >> num;
    a.push_back(num);
  }
  sort((a).begin(), (a).end());
  int res = 0;
  int sum = x;
  int i = 0;
  while (i < N && sum > 0 && x > a[0]) {
    sum -= a[i];
    i++;
    res++;
  }
  if (sum < x && sum != 0) res--;
  cout << res;
}
