#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, a[100], count = 0, m;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  m = n;
  for (int i = 0; i < m; i++) {
    if (x >= a[i]) {
      count++;
      x -= a[i];
    }
  }
  if (x > 0 && count != 0) {
    cout << count - 1 << endl;
  } else {
    cout << count << endl;
  }
  return 0;
}
