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