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