#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long int x, a[110];
  cin >> n >> x;
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  int res = 0;
  for (int i = 0; i < n; ++i) {
    if (x >= a[i]) {
      x -= a[i];
      ++res;
    } else
      break;
  }
  if (x == 0)
    cout << res << endl;
  else
    cout << res - 1 << endl;
}
