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