#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int a[110];
int main(void) {
  ll N, x;
  cin >> N >> x;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  sort(a, a + N);
  int idx = 0;
  while (idx < N && x >= a[idx]) {
    x -= a[idx];
    idx++;
  }
  if (x > 0) idx--;
  cout << idx << endl;
  return 0;
}
