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